forked from web-mighty-io/web-mighty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
58 lines (55 loc) · 1.67 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
58
const glob = require("glob");
const path = require("path");
const FileManagerPlugin = require("filemanager-webpack-plugin");
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = (env) => {
let plugins = [
new FileManagerPlugin({
events: {
onStart: {
delete: [
path.posix.resolve(__dirname, "public/res/js")
]
},
}
})
];
if (!env.docker) {
plugins.push(
new WasmPackPlugin({
crateDirectory: path.posix.resolve(__dirname, "client"),
outDir: path.posix.resolve(__dirname, "public/src/js/pkg"),
})
);
}
return {
mode: "production",
entry: glob.sync(path.posix.resolve(__dirname, "public/src/js/*.js")).reduce((acc, item) => {
const path = item.split("/");
const name = path[path.length - 1].split(".").slice(0, -1).join(".");
acc[name] = item;
return acc;
}, {}),
output: {
path: path.posix.resolve(__dirname, "public/res/js"),
filename: "[name].js"
},
plugins,
experiments: {
syncWebAssembly: true,
topLevelAwait: true,
},
module: {
rules: [{
test: /\.s[ac]ss$/i,
use: ["style-loader", "css-loader", "sass-loader"],
}],
},
watchOptions: {
ignored: [
path.posix.resolve(__dirname, "node_modules"),
path.posix.resolve(__dirname, "public/res")
]
},
};
};