-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
86 lines (80 loc) · 2.79 KB
/
Copy pathwebpack.config.js
File metadata and controls
86 lines (80 loc) · 2.79 KB
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
77
78
79
80
81
82
83
84
85
86
// webpack.config.js – builds the browser.cpp Chrome extension into dist/
const path = require('path');
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const dist = path.resolve(__dirname, 'dist');
// ── UI bundle (Monaco editor + xterm + app logic) ────────────────────────────
const uiConfig = {
name: 'ui',
entry: './src/ui/app.js',
output: {
path: dist,
filename: 'bundle.js',
clean: false,
// Required so Monaco workers can locate themselves at runtime
publicPath: '',
},
module: {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
},
// Monaco ships TTF fonts
{
test: /\.ttf$/,
type: 'asset/resource',
},
],
},
plugins: [
// Emits editor.worker.js and ts.worker.js alongside bundle.js
new MonacoWebpackPlugin({ languages: ['cpp', 'c'] }),
new HtmlWebpackPlugin({
template: './src/ui/index.html',
filename: 'index.html',
// bundle.js is injected by webpack; don't double-inject
inject: 'body',
}),
new MiniCssExtractPlugin({ filename: 'styles.css' }),
new CopyWebpackPlugin({
patterns: [
{ from: 'icons', to: 'icons', noErrorOnMissing: true },
],
}),
],
resolve: {
fallback: {
path: false,
fs: false,
crypto: false,
os: false,
},
},
};
// ── Background service worker ─────────────────────────────────────────────────
const bgConfig = {
name: 'background',
entry: './src/background/service-worker.js',
output: { path: dist, filename: 'service-worker.js', clean: false },
target: 'webworker',
resolve: { fallback: { path: false, fs: false } },
};
const firefoxBgConfig = {
name: 'firefox-background',
entry: './src/background/firefox-background.js',
output: { path: dist, filename: 'firefox-background.js', clean: false },
target: 'web',
resolve: { fallback: { path: false, fs: false } },
};
// ── Compiler web worker ───────────────────────────────────────────────────────
const compilerConfig = {
name: 'compiler-worker',
entry: './src/workers/compiler.worker.js',
output: { path: dist, filename: 'compiler.worker.js', clean: false },
target: 'webworker',
resolve: { fallback: { path: false, fs: false, crypto: false } },
};
module.exports = [uiConfig, bgConfig, firefoxBgConfig, compilerConfig];