-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.config.js
42 lines (41 loc) · 1.18 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
const path = require("path");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const BG_IMAGES_DIRNAME = "bgimages";
const distPath = path.resolve(__dirname, "dist");
module.exports = (env, argv) => {
return {
devServer: {
contentBase: distPath,
compress: argv.mode === "production",
historyApiFallback: {
rewrites: [
// translate everything that is in a sub-directory (e.g. components/form) and contains a dot
// (e.g. components/form/main.js) to the root (e.g. main.js).
{
from: /\/.*?\/(.*\..*)$/,
to: function (context) {
return "/" + context.match[1];
},
},
],
verbose: true,
},
port: 8000,
},
entry: "./main.js",
output: {
path: distPath,
filename: "main.js",
webassemblyModuleFilename: "main.wasm",
},
plugins: [
new CopyWebpackPlugin([{ from: "./static", to: distPath }]),
new WasmPackPlugin({
crateDirectory: ".",
extraArgs: "--no-typescript",
}),
],
watch: argv.mode !== "production",
};
};