Files
Jump/webpack.config.js

78 lines
2.7 KiB
JavaScript
Raw Normal View History

2022-02-07 11:04:54 +00:00
const path = require('path');
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/index.scss',
2022-05-10 15:58:55 +01:00
},
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: /\.(s(a|c)ss)$/,
2022-05-10 15:58:55 +01:00
use: [
{
loader: MiniCssExtractPlugin.loader
},
{
loader: 'css-loader',
2022-05-10 15:58:55 +01:00
options: {
url: false // Stop webpack emitting image/font from URLs found in CSS.
}
},
'sass-loader',
2022-05-10 15:58:55 +01:00
],
}
]
},
plugins: [
new HtmlWebpackPlugin({
filename: path.resolve(__dirname, './jumpapp/templates/header.mustache'),
2022-05-28 20:42:56 +01:00
template: path.resolve(__dirname, './jumpapp/templates/src/header.src.mustache'),
2022-05-10 15:58:55 +01:00
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'),
2022-05-28 20:42:56 +01:00
template: path.resolve(__dirname, './jumpapp/templates/src/footer.src.mustache'),
2022-05-10 15:58:55 +01:00
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({
dry: false,
2022-05-10 15:58:55 +01:00
verbose: true,
cleanStaleWebpackAssets: true,
cleanOnceBeforeBuildPatterns: [
'index.*.min.js',
path.resolve(__dirname, './jumpapp/assets/css/styles.*.min.css')
],
dangerouslyAllowCleanPatternsOutsideProject: true,
})
],
optimization: {
minimizer: [
new Terser({
terserOptions: {
format: {
comments: false,
},
},
extractComments: false,
}),
2022-05-10 15:58:55 +01:00
new CssMinimizerPlugin(),
],
},
};