blob: 795f2b16c9077b3794cec5ba2895e115b6379f30 [file] [log] [blame]
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const path = require('path');
const srcPath = path.resolve(__dirname, 'src');
const elmPath = path.join(srcPath, "elm");
const dstPath = path.resolve(__dirname, 'dist');
module.exports = (env, argv) => ({
entry: './src/main.ts',
output: {
path: dstPath,
filename: 'bundle.js',
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
favicon: 'src/favicon.ico',
}),
new MiniCssExtractPlugin({
filename: 'style.css',
}),
],
optimization: {
minimizer: [
new TerserJSPlugin({}),
new OptimizeCSSAssetsPlugin({}),
],
},
module: {
rules: [
{
test: /\.ts$/,
include: srcPath,
use: 'ts-loader',
},
{
test: /\.elm$/,
include: elmPath,
use: {
loader: 'elm-webpack-loader',
options: {
cwd: elmPath,
debug: argv.mode == "development",
optimize: argv.mode == "production",
}
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
},
],
},
});