-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebpack.web.config.js
100 lines (95 loc) · 3.38 KB
/
webpack.web.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
/* eslint-disable */
//@ts-check
'use strict';
const path = require('path');
const tsconfig_paths_webpack_plugin = require('tsconfig-paths-webpack-plugin');
const webpack = require('webpack');
const constants = require('./build/constants');
const CleanTerminalPlugin = require('clean-terminal-webpack-plugin');
// tslint:disable-next-line:no-var-requires no-require-imports
const configFileName = path.join(constants.ExtensionRootDir, 'tsconfig.extension.web.json');
//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/
/** @type WebpackConfig */
const extensionConfig = {
target: 'webworker', // 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')
entry: './src/extension.web.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
output: {
filename: 'web.main.js',
path: path.resolve(constants.ExtensionRootDir, 'out'),
libraryTarget: 'commonjs2'
},
node: {
__dirname: false,
__filename: false
},
externals: ['vscode', 'commonjs', 'electron', 'crypto'], // Don't bundle these,
plugins: [
// Work around for Buffer is undefined:
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer']
}),
new webpack.ProvidePlugin({
process: 'process/browser' // provide a shim for the global `process` variable
}),
new webpack.DefinePlugin({
// Definitions...
BROWSER: JSON.stringify(true),
process: {
platform: JSON.stringify('web')
}
}),
new CleanTerminalPlugin()
],
resolve: {
extensions: ['.ts', '.js'],
mainFields: ['browser', 'module', 'main'], // look for `browser` entry point in imported node modules
plugins: [
new tsconfig_paths_webpack_plugin.TsconfigPathsPlugin({ configFile: configFileName, logLevel: 'INFO' })
],
alias: {
// provides alternate implementation for node module and source files
},
fallback: {
// Webpack 5 no longer polyfills Node.js core modules automatically.
// see https://webpack.js.org/configuration/resolve/#resolvefallback
// for the list of Node.js core module polyfills.
assert: require.resolve('assert'),
buffer: require.resolve('buffer'),
os: require.resolve('os-browserify/browser')
}
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/],
use: [
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.json'
}
}
]
},
{
test: /\.svg$/,
use: ['svg-inline-loader']
}
]
},
infrastructureLogging: {
level: 'log' // enables logging required for problem matchers
},
watchOptions: {
aggregateTimeout: 200,
poll: 1000,
ignored: /node_modules/
},
stats: {
builtAt: true
}
};
module.exports = [extensionConfig];