-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.config.js
49 lines (48 loc) · 1.52 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WasmPackPlugin = require("@wasm-tool/wasm-pack-plugin");
module.exports = (_, argv) => {
console.log('Building in %s mode', argv.mode);
config = {
entry: './index.ts',
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html'
}),
new WasmPackPlugin({
// See https://github.com/GoogleChromeLabs/wasm-bindgen-rayon/#readme
// Other compilation flags provided in npm scripts, see `package.json`
extraArgs: "--target web -- . -Z build-std=panic_abort,std",
crateDirectory: path.resolve(__dirname, ".")
})
],
experiments: {
asyncWebAssembly: true
},
devServer: {
// Required in order to use SharedArrayBuffer
// See https://web.dev/coop-coep/
headers: {
'Cross-Origin-Embedder-Policy': 'require-corp',
'Cross-Origin-Opener-Policy': 'same-origin',
}
}
};
return config;
}