-
Notifications
You must be signed in to change notification settings - Fork 282
/
webpack.config.js
84 lines (83 loc) · 3.25 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
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const isProd = process.argv.indexOf('--mode=production') >= 0;
var webpack = require('webpack');
module.exports = [
{
target: "node",
node: {
fs: 'empty', net: 'empty', tls: 'empty',
child_process: 'empty', dns: 'empty',
global: true, __dirname: true
},
entry: ['./src/extension.ts'],
output: {
path: path.resolve(__dirname, 'out'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '[absoluteResourcePath]',
},
externals: {
vscode: 'commonjs vscode',
mockjs: 'mockjs vscode',
'mongodb-client-encryption':'mongodb-client-encryption'
},
resolve: {
extensions: ['.ts', '.js'],
alias: {
'@': path.resolve(__dirname, './src')
}
},
plugins: [
new webpack.IgnorePlugin(/^(pg-native|cardinal|encoding|aws4)$/)
],
module: { rules: [{ test: /\.ts$/, exclude: /(node_modules|bin)/, use: ['ts-loader'] }] },
optimization: { minimize: isProd },
watch: !isProd,
mode: isProd ? 'production' : 'development',
devtool: isProd ? false : 'source-map',
},
{
entry: {
app: './src/vue/main.js',
query: './src/vue/result/main.js'
},
plugins: [
new VueLoaderPlugin(),
new HtmlWebpackPlugin({ inject: true, template: './public/index.html', chunks: ['app'], filename: 'webview/app.html' }),
new HtmlWebpackPlugin({ inject: true, templateContent: `<head><script src="js/oldCompatible.js"></script></head><body> <div id="app"></div> </body>`, chunks: ['query'], filename: 'webview/result.html' }),
new CopyWebpackPlugin({
patterns: [{ from: 'public', to: './webview' }]
}),
],
output: {
path: path.resolve(__dirname, 'out'),
filename: 'webview/js/[name].js'
},
resolve: {
extensions: ['.vue', '.js'],
alias: { 'vue$': 'vue/dist/vue.esm.js', '@': path.resolve('src'), }
},
module: {
rules: [
{ test: /\.vue$/, loader: 'vue-loader', options: { loaders: { css: ["vue-style-loader", "css-loader"] } } },
{ test: /(\.css|\.cssx)$/, use: ["vue-style-loader", "css-loader", { loader: "postcss-loader" }] },
{ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, loader: 'url-loader', options: { limit: 80000 } }
]
},
optimization: {
minimize: isProd,
splitChunks: {
cacheGroups: {
antv: { name: "antv", test: /[\\/]@antv[\\/]/, chunks: "all", priority: 10 },
vendor: { name: "vendor", test: /[\\/]node_modules[\\/]/, chunks: "all", priority: -1 }
}
}
},
watch: !isProd,
mode: isProd ? 'production' : 'development',
devtool: isProd ? false : 'source-map',
}
];