-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.plugin.js
76 lines (73 loc) · 3.04 KB
/
webpack.plugin.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
68
69
70
71
72
73
74
75
76
/* eslint-disable @typescript-eslint/no-var-requires */
// eslint-disable-next-line no-undef
const { ProvidePlugin, DefinePlugin } = require("webpack");
// eslint-disable-next-line no-undef
const CopyPlugin = require("copy-webpack-plugin");
const webpackPlugin = (context, options) => {
return {
name: "webpack-plugin",
configureWebpack(config) {
config.module.rules.forEach((rule) => {
rule.resourceQuery = { not: [/raw/] };
});
config.module.rules.push({
resourceQuery: /raw/,
type: "asset/source",
});
return {
plugins: [
new DefinePlugin({
"process.env.DEBUG": "runtime_process_env.DEBUG",
// eslint-disable-next-line no-undef
WEB_API_VERSION: JSON.stringify(require("./@novorender/package.json").version),
// eslint-disable-next-line no-undef
WEB_API_TYPESCRIPT_VERSION: JSON.stringify(require("./@novorender/package.json").devDependencies["typescript"])
}),
new ProvidePlugin({
// eslint-disable-next-line no-undef
process: require.resolve("process/browser"),
}),
new CopyPlugin({
patterns: [
{
from: "node_modules/@novorender/api/public/*",
to: "[name][ext]",
},
],
}),
],
// resolve: {
// fallback: {
// // eslint-disable-next-line no-undef
// stream: require.resolve("stream-browserify"),
// // eslint-disable-next-line no-undef
// path: require.resolve("path-browserify"),
// // eslint-disable-next-line no-undef
// buffer: require.resolve("buffer/"),
// // eslint-disable-next-line no-undef
// util: require.resolve("util/"),
// // eslint-disable-next-line no-undef
// url: require.resolve("url/"),
// },
// alias: {
// process: "process/browser.js",
// },
// },
module: {},
devServer: {
headers: {
"Cross-Origin-Opener-Policy": "same-origin",
"Cross-Origin-Embedder-Policy": "require-corp",
},
client: {
overlay: {
runtimeErrors: false,
},
},
},
};
},
};
};
// eslint-disable-next-line no-undef
module.exports = { webpackPlugin };