49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
const path = require('path');
|
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
|
|
module.exports = (env, argv) => {
|
|
const isProd = argv.mode === 'production';
|
|
|
|
return {
|
|
entry: './fabula-ultima-sheet.js',
|
|
output: {
|
|
filename: isProd ? 'bundle.[contenthash].js' : 'bundle.js',
|
|
path: path.resolve(__dirname, 'dist'),
|
|
clean: true,
|
|
// Disable IIFE wrapping so onclick= handlers can reach global functions
|
|
iife: false,
|
|
},
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.css$/,
|
|
use: [
|
|
isProd ? MiniCssExtractPlugin.loader : 'style-loader',
|
|
'css-loader',
|
|
],
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
...(isProd
|
|
? [new MiniCssExtractPlugin({ filename: 'styles.[contenthash].css' })]
|
|
: []),
|
|
new HtmlWebpackPlugin({
|
|
template: './fabula-ultima-sheet.html',
|
|
filename: 'index.html',
|
|
scriptLoading: 'blocking',
|
|
}),
|
|
],
|
|
optimization: {
|
|
minimizer: ['...', new CssMinimizerPlugin()],
|
|
},
|
|
devServer: {
|
|
static: { directory: path.resolve(__dirname, 'dist') },
|
|
port: 8080,
|
|
open: true,
|
|
},
|
|
};
|
|
};
|