-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.ts
76 lines (73 loc) · 2.25 KB
/
webpack.config.ts
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
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
import * as path from 'path';
import TerserPlugin from 'terser-webpack-plugin';
import * as webpack from 'webpack';
let mode = process.argv.includes('--mode')
? process.argv[process.argv.indexOf('--mode') + 1]
: 'development';
if (!['development', 'production'].includes(mode)) {
mode = 'production';
}
console.log(`Building in ${mode} mode`);
const cacheDirectory = path.resolve(__dirname, '.webpack');
const isDev = mode === 'development';
const extensionConfig: webpack.Configuration = {
target: 'node',
entry: './src/extension.ts',
cache: isDev ? { type: 'filesystem', cacheDirectory } : false,
devtool: isDev ? 'source-map' : false,
output: {
filename: 'extension.js',
libraryTarget: 'commonjs2',
path: path.resolve(__dirname, 'dist')
},
resolve: { extensions: ['.ts', '.js'] },
module: { rules: [{ test: /\.ts$/, loader: 'ts-loader' }] },
optimization: {
minimize: true,
minimizer: [new TerserPlugin()]
},
externals: { vscode: 'commonjs vscode' },
infrastructureLogging: {
level: 'log' // enables logging required for problem matchers
}
};
const webviewConfig: webpack.Configuration = {
target: 'web',
entry: './src/web/index.tsx',
cache: isDev ? { type: 'filesystem', cacheDirectory } : false,
devtool: isDev ? 'source-map' : false,
plugins: [new MiniCssExtractPlugin()],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
resolve: {
extensions: ['.js', '.ts', '.tsx', '.css']
},
externals: {
vscode: 'commonjs vscode'
},
module: {
rules: [
{ test: /\.tsx?$/, use: ['babel-loader', 'ts-loader'] },
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
optimization: {
minimize: true,
minimizer: [new TerserPlugin()]
},
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
},
infrastructureLogging: {
level: 'log' // enables logging required for problem matchers
}
};
export default [webviewConfig, extensionConfig];