-
Notifications
You must be signed in to change notification settings - Fork 6
/
webpack.config.js
74 lines (72 loc) · 2.73 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
68
69
70
71
72
73
74
const path = require("path");
const { monacoModDir } = require("./setup");
const monacoModPath = path.resolve(__dirname, "node_modules", monacoModDir);
const nls = require.resolve("./nls-replace.js");
const LimitChunkCountPlugin = require("webpack/lib/optimize/LimitChunkCountPlugin");
const NormalModuleWebpackReplacementPlugin = require("webpack/lib/NormalModuleReplacementPlugin");
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
module.exports = (env, argv) => {
const devMode = ["development", "dev"].includes(argv?.mode || "production");
env = env || {};
env.production = env.production === true || env.production === "true" || !devMode
// env.production = false; // force dev mode build
if (env.production) {
console.log("Running webpack in production mode");
} else {
console.log("Running webpack in development mode");
}
return {
mode: env.production ? "production" : "development",
devtool: env.production ? undefined : "inline-source-map",
entry: { editor: "./index.js" },
output: {
path: path.resolve(__dirname, "output", "monaco", "dist"),
filename: 'editor.js'
},
stats: {
assets: true,
children: true,
chunks: false,
errors: true,
errorDetails: true,
modules: false,
timings: true,
colors: true
},
target: ['web', 'es6'],
module: {
rules: [{
test: /\.css$/,
use: ["style-loader", "css-loader"],
}, {
test: /\.ttf$/,
type: 'asset/resource'
}
]
},
plugins: [
new NormalModuleWebpackReplacementPlugin(/\/(vscode\-)?nls\.js/, function (resource) {
resource.request = nls;
resource.resource = nls;
}),
new MonacoWebpackPlugin({ globalAPI: true, monacoEditorPath: monacoModPath }),
new LimitChunkCountPlugin({
maxChunks: 1,
}),
new CopyWebpackPlugin({
patterns: [
{ from: 'node_modules/monaco-themes/LICENSE', to: "theme" },
{ from: 'node_modules/monaco-editor-esm-i18n/ThirdPartyNotices.txt', to: "ThirdPartyNotices.txt" },
{ from: 'node_modules/monaco-editor-esm-i18n/LICENSE', to: "LICENSE", toType: "file" }
]
}),
],
optimization: {
minimize: env.production ? true : false,
splitChunks: {
minSize: 9999999999999999,
}
}
};
};