forked from microsoft/vscode-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
135 lines (126 loc) Β· 5.74 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check // Check this file for typing issues (helps prevent mistakes in options passed)
/* eslint-disable no-undef */ // Ignore the fact that the engine (which is webpack) is unknown
'use strict';
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
/* eslint-enable @typescript-eslint/no-var-requires */
const debugWebpack = !!process.env.DEBUG_WEBPACK;
/** @type {import('webpack').Configuration} */ // Here's where we can get typing help even though it's JS
const config = {
target: 'node', // vscode extensions run in a Node.js-context π -> https://webpack.js.org/configuration/node/
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
cache: true, // Makes 'watch' builds way faster after the first full build
entry: {
/* eslint-disable @typescript-eslint/naming-convention */
'./extension.bundle': './src/extension.ts',
'./dockerfile-language-server-nodejs/lib/server': './node_modules/dockerfile-language-server-nodejs/lib/server.js',
'./compose-language-service/lib/server': './node_modules/@microsoft/compose-language-service/lib/server.js',
/* eslint-enable @typescript-eslint/naming-convention */
}, // the entry point of this extension, π -> https://webpack.js.org/configuration/entry-context/
output: {
// the bundle is stored in the 'dist' folder (check package.json), π -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'commonjs2'
},
devtool: 'nosources-source-map',
externals: {
vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, π -> https://webpack.js.org/configuration/externals/
},
resolve: {
// support reading TypeScript and JavaScript files, π -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js']
},
module: {
rules: [
{
// Default TypeScript loader for .ts files
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader'
}
]
},
{
// Unpack UMD module headers used in some modules since webpack doesn't handle them.
test: /dockerfile-language-service|vscode-languageserver-types/,
use: { loader: 'umd-compat-loader' }
},
{
test: /\.node$/,
loader: 'node-loader',
},
]
},
plugins: [
// Copy some needed resource files from external sources
new CopyPlugin({
patterns: [
'./node_modules/@microsoft/vscode-azext-azureutils/resources/**/*.svg',
],
}),
],
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
/* eslint-disable @typescript-eslint/naming-convention */
// Keep class and function names so that stacks aren't useless and things like UserCancelledError work
keep_classnames: true,
keep_fnames: true,
/* eslint-enable @typescript-eslint/naming-convention */
}
}),
]
},
ignoreWarnings: [
// Suppress some webpack warnings caused by dependencies
{
// Ignore some warnings from handlebars in code that doesn't get used anyway
module: /node_modules\/handlebars\/lib\/index\.js/,
message: /require\.extensions/,
},
{
// Ignore a warning from `@vscode/extension-telemetry`
module: /node_modules\/@vscode\/extension-telemetry/,
message: /Can't resolve 'applicationinsights-native-metrics'/
},
{
// Ignore a warning for missing optional dependency of `ssh2`
module: /node_modules\/ssh2/,
message: /Can't resolve 'cpu-features'/
},
{
// Ignore another warning for missing optional dependency of `ssh2`, if VS build tools aren't installed
module: /node_modules\/ssh2/,
message: /Can't resolve '.\/crypto\/build\/Release\/sshcrypto.node'/
},
{
// Ignore a warning for a missing optional dependency of `ws` via `@microsoft/vscode-azext-azureappservice`
module: /node_modules\/ws/,
message: /Can't resolve 'bufferutil'/
},
{
// Ignore another warning for a missing optional dependency of `ws` via `@microsoft/vscode-azext-azureappservice`
module: /node_modules\/ws/,
message: /Can't resolve 'utf-8-validate'/
},
(warning) => false, // No other warnings should be ignored
],
};
if (debugWebpack) {
// @ts-expect-error for a spurious type incompatibility
config.plugins.push(new BundleAnalyzerPlugin({ analyzerMode: 'static' }));
console.log('Config:', config);
}
module.exports = config;
/* eslint-enable no-undef */