-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
57 lines (49 loc) · 1.26 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCSSExtractPlugin = require("mini-css-extract-plugin");
const TerserJSPlugin = require('terser-webpack-plugin');
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");
const production = process.env.NODE_ENV == "production";
module.exports = {
entry: "./index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: production ? "index-[hash:8].js" : "index.js",
},
resolve: {
alias: {
"wasm-pkg": path.resolve(__dirname, 'pkg')
}
},
mode: production ? "production" : "development",
optimization: {
minimizer: [
new TerserJSPlugin({}),
new OptimizeCSSAssetsPlugin({})
]
},
plugins: [
new CopyPlugin([
{from: "roms/*.ch8", to: "roms", flatten: true},
{from: "assets", to: "assets"},
]),
new HtmlWebpackPlugin({
template: 'index.html',
}),
new MiniCSSExtractPlugin({
filename: production ? "style-[hash:8].css" : "style.css"
})
],
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCSSExtractPlugin.loader,
"css-loader"
]
}
]
}
};