forked from microsoft/vscode-edge-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
89 lines (86 loc) · 2.85 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// @ts-check
/* eslint-disable @typescript-eslint/no-var-requires */
const copyPlugin = require('copy-webpack-plugin');
const path = require('path');
const { DefinePlugin } = require('webpack');
/** @type {Partial<import('webpack').Configuration>} */
const commonConfig = {
devtool: 'source-map',
mode: 'production',
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: 'ts-loader',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
};
/**
* @param {Record<string, unknown>} env
* @returns {import('webpack').Configuration | import('webpack').Configuration[]}
*/
module.exports = env => {
return [
{
...commonConfig,
entry: {
host: './src/host/mainHost.ts',
},
name: 'host',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'out/host'),
},
},
{
...commonConfig,
entry: {
screencast: './src/screencast/main.ts',
},
name: 'screencast',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'out/screencast'),
},
},
{
...commonConfig,
entry: {
extension: './src/extension.ts',
},
externals: {
vscode: 'commonjs vscode',
'applicationinsights-native-metrics': 'commonjs applicationinsights-native-metrics', // We're not native
},
name: 'extension',
target: 'node',
output: {
devtoolModuleFilenameTemplate: '../[resource-path]',
filename: '[name].js',
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, 'out'),
},
// Copy startpage html to output bundle
plugins: [
new copyPlugin({
patterns: [
{ from: 'startpage', to: 'startpage' },
{ from: 'src/common/styles.css', to: 'common/styles.css' },
{ from: 'icon.png', to: 'icon.png' },
{ from: 'src/screencast/view.css', to: 'screencast/view.css' },
],
}),
// These must also be defined in the jest section of package.json for tests to pass
new DefinePlugin({
DEBUG: JSON.stringify(env.debug ?? false),
DEVTOOLS_BASE_URI: JSON.stringify(env.devtoolsBaseUri ?? undefined),
})
],
},
];
};