-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
67 lines (66 loc) · 1.95 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
59
60
61
62
63
64
65
66
67
const fs = require("fs");
const path = require("path");
const CopyPlugin = require("copy-webpack-plugin");
module.exports = (env, argv) => {
return {
node: { global: true },
mode: "development",
entry: "./src/index.js",
...(argv.mode === "production"
? {
optimization: {
minimize: false,
},
}
: { devtool: "inline-source-map" }),
output: {
path: path.join(__dirname, "dist"),
filename: "app.js",
library: {
name: "app",
type: "umd",
},
globalObject: `(typeof self !== 'undefined' ? self : this)`,
},
performance: {
hints: false,
},
devServer: {
static: [{ directory: path.join(__dirname, "public") }],
compress: true,
port: 9000,
open: true,
},
plugins: [
// Copy files pyodide.js will load asynchronously
new CopyPlugin({
patterns: [
{ from: require.resolve("pyodide/distutils.tar"), to: "pyodide/distutils.tar" },
{ from: require.resolve("pyodide/packages.json"), to: "pyodide/packages.json" },
{ from: require.resolve("pyodide/pyodide_py.tar"), to: "pyodide/pyodide_py.tar" },
{ from: require.resolve("pyodide/pyodide.asm.data"), to: "pyodide/pyodide.asm.data" },
{ from: require.resolve("pyodide/pyodide.asm.js"), to: "pyodide/pyodide.asm.js" },
{ from: require.resolve("pyodide/pyodide.asm.wasm"), to: "pyodide/pyodide.asm.wasm" },
],
}),
],
module: {
noParse: /pyodide\.js/,
rules: [
// Remove pyodide globals. They are not necessary when using pyodide in webpack
{
test: /pyodide\/.+\.js$/,
loader: "string-replace-loader",
options: {
multiple: [
{
search: "globalThis.loadPyodide=loadPyodide",
replace: "({})",
},
],
},
},
],
},
};
};