2022-02-07 11:04:54 +00:00
|
|
|
const path = require('path');
|
2022-03-16 14:42:58 +00:00
|
|
|
const Terser = require('terser-webpack-plugin');
|
2022-05-10 15:58:55 +01:00
|
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
|
|
|
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
|
|
|
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
2022-02-07 11:04:54 +00:00
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
mode: 'production',
|
2022-05-10 15:58:55 +01:00
|
|
|
entry: {
|
|
|
|
|
index: './jumpapp/assets/js/src/index.js',
|
|
|
|
|
styles: './jumpapp/assets/css/src/styles.css',
|
|
|
|
|
},
|
2022-02-07 11:04:54 +00:00
|
|
|
output: {
|
2022-05-10 15:58:55 +01:00
|
|
|
filename: '[name].[contenthash].min.js',
|
2022-02-07 11:04:54 +00:00
|
|
|
path: path.resolve(__dirname, './jumpapp/assets/js/'),
|
|
|
|
|
},
|
2022-05-10 15:58:55 +01:00
|
|
|
module: {
|
|
|
|
|
rules: [
|
|
|
|
|
{
|
|
|
|
|
test: /\.css$/,
|
|
|
|
|
use: [
|
|
|
|
|
{
|
|
|
|
|
loader: MiniCssExtractPlugin.loader
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
loader: "css-loader",
|
|
|
|
|
options: {
|
|
|
|
|
url: false // Stop webpack emitting image/font from URLs found in CSS.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
plugins: [
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
|
filename: path.resolve(__dirname, './jumpapp/templates/header.mustache'),
|
|
|
|
|
template: path.resolve(__dirname, './jumpapp/templates/src/header.mustache'),
|
|
|
|
|
inject: false,
|
|
|
|
|
minify: false, // Required to prevent addition of closing tags like body and html.
|
|
|
|
|
}),
|
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
|
filename: path.resolve(__dirname, './jumpapp/templates/footer.mustache'),
|
|
|
|
|
template: path.resolve(__dirname, './jumpapp/templates/src/footer.mustache'),
|
|
|
|
|
inject: false,
|
|
|
|
|
minify: false, // Required to prevent addition of closing tags like body and html.
|
|
|
|
|
}),
|
|
|
|
|
new MiniCssExtractPlugin({filename: '../css/[name].[contenthash].min.css'}),
|
|
|
|
|
new RemoveEmptyScriptsPlugin(),
|
|
|
|
|
new CleanWebpackPlugin({
|
|
|
|
|
verbose: true,
|
|
|
|
|
cleanStaleWebpackAssets: true,
|
|
|
|
|
cleanOnceBeforeBuildPatterns: [
|
|
|
|
|
'index.*.min.js',
|
|
|
|
|
path.resolve(__dirname, './jumpapp/assets/css/styles.*.min.css')
|
|
|
|
|
],
|
|
|
|
|
dangerouslyAllowCleanPatternsOutsideProject: true,
|
|
|
|
|
})
|
|
|
|
|
],
|
2022-03-16 14:42:58 +00:00
|
|
|
optimization: {
|
|
|
|
|
minimizer: [
|
|
|
|
|
new Terser({
|
|
|
|
|
terserOptions: {
|
|
|
|
|
format: {
|
|
|
|
|
comments: false,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
extractComments: false,
|
|
|
|
|
}),
|
2022-05-10 15:58:55 +01:00
|
|
|
new CssMinimizerPlugin(),
|
2022-03-16 14:42:58 +00:00
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|