-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
45 lines (43 loc) · 1.15 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
const path = require("path");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
const distPath = path.resolve(__dirname, "dist");
var mode = process.env.NODE_ENV || "development";
module.exports = {
devtool: mode === "development" ? "inline-source-map" : false,
mode: mode,
devServer: {
port: 8000,
},
entry: "./bootstrap.js",
output: {
path: distPath,
filename: "index.js",
webassemblyModuleFilename: "pkg.wasm",
clean: true,
},
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: "./static", to: distPath }],
}),
new WasmPackPlugin({
crateDirectory: ".",
extraArgs: "-- --features wee_alloc",
outName: "index",
forceMode: mode,
forceWatch: true,
watchOptions: {
aggregateTimeout: 200,
poll: 200,
// is not necessary as long as you remove pkg/* before building your wasm files
},
watchDirectories: [
// make distinct from outDir
path.resolve(__dirname, "./src"), // point to rs src
],
}),
],
experiments: {
syncWebAssembly: true,
},
};