-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathwebpack.config.js
50 lines (45 loc) · 1.42 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
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const { ModuleFederationPlugin } = require('webpack').container;
// @TODO: uncomment this if you want to dev on the Rust src code.
const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin');
const dist = path.resolve(__dirname, 'dist');
module.exports = {
entry: {
index: './public/index.js',
},
output: {
path: dist,
filename: '[name].js',
},
devServer: {
port: 8081,
static: {
directory: path.join(__dirname, 'dist'),
},
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, PATCH, OPTIONS',
'Access-Control-Allow-Headers': 'X-Requested-With, content-type, Authorization',
},
},
experiments: { asyncWebAssembly: true },
plugins: [
new CopyPlugin({ patterns: [{ from: path.resolve(__dirname, '') }] }),
// @TODO: uncomment this if you want to dev on the Rust src code.
// Webpack will load the Rust code and compile it to Wasm using Wasm-Pack.
// Wasm-pack will also generate all the JS bindings needed to interop with JS,
// found in the `./pkg` directory.
//
// new WasmPackPlugin({
// crateDirectory: __dirname,
// }),
new ModuleFederationPlugin({
name: 'GameOfLifeModule',
filename: 'remoteEntry.js',
exposes: {
'./GameOfLifeModule': './pkg/',
},
}),
],
};