-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
69 lines (58 loc) · 2.76 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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
//@ts-check
// See https://github.com/Microsoft/vscode-azuretools/wiki/webpack for guidance
const process = require('process');
const dev = require("@microsoft/vscode-azext-dev");
const webpack = require('webpack');
const path = require('path');
let DEBUG_WEBPACK = !/^(false|0)?$/i.test(process.env.DEBUG_WEBPACK || '');
let nodeConfig = dev.getDefaultWebpackConfig({
projectRoot: __dirname,
verbosity: DEBUG_WEBPACK ? 'debug' : 'normal',
externals:
{
// Fix "Module not found" errors in ./node_modules/websocket/lib/{BufferUtil,Validation}.js
// These files are not in node_modules and so will fail normally at runtime and instead use fallbacks.
// Make them as external so webpack doesn't try to process them, and they'll simply fail at runtime as before.
'../build/Release/validation': 'commonjs ../build/Release/validation',
'../build/default/validation': 'commonjs ../build/default/validation',
'../build/Release/bufferutil': 'commonjs ../build/Release/bufferutil',
'../build/default/bufferutil': 'commonjs ../build/default/bufferutil',
},
target: 'node',
suppressCleanDistFolder: true
});
const nodeSrcPath = path.resolve(__dirname, 'src/node');
const alias = {};
alias[nodeSrcPath] = path.resolve(__dirname, 'src/browser');
let webConfig = dev.getDefaultWebpackConfig({
projectRoot: __dirname,
verbosity: DEBUG_WEBPACK ? 'debug' : 'normal',
externals:
{
// Fix "Module not found" errors in ./node_modules/websocket/lib/{BufferUtil,Validation}.js
// These files are not in node_modules and so will fail normally at runtime and instead use fallbacks.
// Make them as external so webpack doesn't try to process them, and they'll simply fail at runtime as before.
'../build/Release/validation': 'commonjs ../build/Release/validation',
'../build/default/validation': 'commonjs ../build/default/validation',
'../build/Release/bufferutil': 'commonjs ../build/Release/bufferutil',
'../build/default/bufferutil': 'commonjs ../build/default/bufferutil',
},
target: 'webworker',
plugins: [new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
})],
suppressCleanDistFolder: true,
resolveFallbackAliases: {
'constants': false
},
alias
});
if (DEBUG_WEBPACK) {
console.log('Config:', nodeConfig);
}
module.exports = [nodeConfig, webConfig];