Skip to content

Commit f988b91

Browse files
committed
update webpack config
1 parent d1406d6 commit f988b91

File tree

4 files changed

+106
-53
lines changed

4 files changed

+106
-53
lines changed

.vscode/tasks.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"regexp": "webpack is watching the files"
2929
},
3030
"endsPattern": {
31-
"regexp": "extension = extension.js"
31+
"regexp": "Entrypoint HtmlWebpackPlugin_0"
3232
}
3333
}
3434
}

package-lock.json

+24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -747,6 +747,7 @@
747747
"cardinal": "^2.1.1",
748748
"clean-webpack-plugin": "^3.0.0",
749749
"css-loader": "^3.5.3",
750+
"extract-text-webpack-plugin": "^4.0.0-beta.0",
750751
"file-loader": "^6.0.0",
751752
"html-webpack-plugin": "^4.3.0",
752753
"style-loader": "^1.2.1",

webpack.config.js

+80-52
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,87 @@ const isProd = process.argv.indexOf('-p') >= 0;
22
const path = require('path');
33
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
44
const { VueLoaderPlugin } = require('vue-loader')
5+
const ExtractTextPlugin = require('extract-text-webpack-plugin')
56
const HtmlWebpackPlugin = require('html-webpack-plugin')
67

7-
module.exports = {
8-
node: {
9-
fs: 'empty', net: 'empty', tls: 'empty',
10-
child_process: 'empty', dns: 'empty',
11-
global: true, __dirname: true
8+
module.exports = [
9+
{
10+
target: "node",
11+
node: {
12+
fs: 'empty', net: 'empty', tls: 'empty',
13+
child_process: 'empty', dns: 'empty',
14+
global: true, __dirname: true
15+
},
16+
entry: ['./src/extension.ts'],
17+
output: {
18+
path: path.resolve(__dirname, 'out'),
19+
filename: 'extension.js',
20+
libraryTarget: 'commonjs2'
21+
},
22+
externals: {
23+
vscode: 'commonjs vscode'
24+
},
25+
resolve: {
26+
extensions: ['.ts', '.js']
27+
},
28+
module: { rules: [{ test: /\.ts$/, exclude: /node_modules/, use: ['ts-loader'] }] },
29+
watch: !isProd,
30+
optimization: {
31+
minimize: false
32+
},
33+
mode: isProd ? 'production' : 'development',
34+
devtool: isProd ? false : 'source-map',
1235
},
13-
entry: {
14-
extension: './src/extension.ts',
15-
query: './src/vue/pages/result/main.js'
16-
},
17-
output: {
18-
path: path.resolve(__dirname, 'out'),
19-
filename: '[name].js',
20-
devtoolModuleFilenameTemplate: '../[resource-path]'
21-
},
22-
externals: {
23-
vscode: 'commonjs vscode'
24-
},
25-
resolve: {
26-
extensions: ['.ts', '.vue', '.js'],
27-
alias: {
28-
'vue$': 'vue/dist/vue.esm.js',
29-
'@': path.resolve('src'),
30-
}
31-
},
32-
module: {
33-
rules: [
34-
{ test: /\.vue$/, loader: 'vue-loader', options: { loaders: { css: ["vue-style-loader", "css-loader"], optimizeSSR: false } } },
35-
{ test: /\.ts$/, exclude: /node_modules/, use: ['ts-loader'] },
36-
{ test: /\.css$/, use: ["vue-style-loader", 'css-loader'] },
37-
{
38-
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
39-
loader: 'url-loader',
40-
options: {
41-
limit: 10000
42-
}
36+
{
37+
entry: {
38+
query: './src/vue/pages/result/main.js'
39+
},
40+
output: {
41+
path: path.resolve(__dirname, 'out'),
42+
filename: '[name].js'
43+
},
44+
resolve: {
45+
extensions: ['.vue', '.js'],
46+
alias: {
47+
'vue$': 'vue/dist/vue.esm.js',
48+
'@': path.resolve('src'),
4349
}
44-
]
45-
},
46-
plugins: [
47-
new VueLoaderPlugin(),
48-
new HtmlWebpackPlugin({
49-
filename: '../resources/webview/pages/result/index.html', template: './src/vue/pages/result/index.html',
50-
chunks: ['query'], inject: true
51-
}),
52-
new CleanWebpackPlugin({ cleanStaleWebpackAssets: false })
53-
],
54-
watch: !isProd,
55-
optimization: {
56-
minimize: isProd
57-
},
58-
mode: isProd ? 'production' : 'development',
59-
devtool: isProd ? false : 'source-map',
60-
};
50+
},
51+
module: {
52+
rules: [
53+
// {
54+
// test: /index\.css$/, use: ExtractTextPlugin.extract({
55+
// fallback: "vue-style-loader",
56+
// use: "css-loader"
57+
// })
58+
// },
59+
{ test: /\.vue$/, loader: 'vue-loader', options: { loaders: { css: ["vue-style-loader", "css-loader"] } } },
60+
{
61+
test: /\.css$/, use: ["vue-style-loader", "css-loader"]
62+
},
63+
{
64+
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
65+
loader: 'url-loader',
66+
options: {
67+
limit: 80000
68+
}
69+
}
70+
]
71+
},
72+
plugins: [
73+
new ExtractTextPlugin("styles.css"),
74+
new VueLoaderPlugin(),
75+
new HtmlWebpackPlugin({
76+
filename: '../resources/webview/pages/result/index.html', template: './src/vue/pages/result/index.html',
77+
chunks: ['query'], inject: true
78+
}),
79+
new CleanWebpackPlugin({ cleanStaleWebpackAssets: false })
80+
],
81+
watch: !isProd,
82+
optimization: {
83+
minimize: false
84+
},
85+
mode: isProd ? 'production' : 'development',
86+
devtool: isProd ? false : 'source-map',
87+
}
88+
];

0 commit comments

Comments
 (0)