95 lines
2.4 KiB
JavaScript
95 lines
2.4 KiB
JavaScript
const path = require('path');
|
|
const webpack = require('webpack');
|
|
const CopyPlugin = require('copy-webpack-plugin');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
const TerserJSPlugin = require('terser-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
|
|
module.exports = {
|
|
entry: {
|
|
index: './index.js'
|
|
},
|
|
output: {
|
|
filename: '[name].[contenthash].js',
|
|
path: path.resolve(__dirname, 'dist'),
|
|
publicPath: ''
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
loaders: [MiniCssExtractPlugin.loader, "css-loader"]
|
|
},
|
|
{
|
|
test: { and: [ /\.(jpe?g|png|gif|svg)$/i, /jquery-ui/i ] },
|
|
loader: "file-loader",
|
|
options: {
|
|
name: '[name].[contenthash].[ext]',
|
|
outputPath: 'assets/jquery-ui'
|
|
}
|
|
},
|
|
{
|
|
test: { and: [ /\.(jpe?g|png|gif)$/i, { not: [ /jquery-ui/i ] } ] },
|
|
loader: "file-loader",
|
|
options: {
|
|
name: '[path][name].[contenthash].[ext]',
|
|
outputPath: 'assets/'
|
|
}
|
|
},
|
|
{
|
|
test: { and: [ /\.svg$/i, { not: [ /jquery-ui/i ] } ] },
|
|
use: [
|
|
{
|
|
loader: "file-loader",
|
|
options: {
|
|
name: '[path][name].[contenthash].[ext]',
|
|
outputPath: 'assets/'
|
|
}
|
|
},
|
|
{ loader: "svgo-loader" }
|
|
]
|
|
}
|
|
]
|
|
},
|
|
plugins: [
|
|
new CleanWebpackPlugin(),
|
|
new HtmlWebpackPlugin({
|
|
title: 'Paco Ŝako',
|
|
template: 'index.html',
|
|
}),
|
|
new MiniCssExtractPlugin({
|
|
filename: '[name].[contenthash].css',
|
|
chunkFilename: '[id].[contenthash].css',
|
|
}),
|
|
new webpack.ProvidePlugin({
|
|
$: "jquery",
|
|
jQuery: "jquery",
|
|
"window.jQuery": "jquery'",
|
|
"window.$": "jquery"
|
|
}),
|
|
new CopyPlugin([
|
|
{ from: '.htaccess' },
|
|
]),
|
|
],
|
|
optimization: {
|
|
moduleIds: 'hashed',
|
|
minimizer: [
|
|
new TerserJSPlugin({}),
|
|
new OptimizeCSSAssetsPlugin({}),
|
|
],
|
|
splitChunks: {
|
|
chunks: 'all',
|
|
cacheGroups: {
|
|
vendor: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name: 'vendors',
|
|
chunks: 'all',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
/* vim:set expandtab sw=2 ts=8: */
|