-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwebpack.config.js
66 lines (64 loc) · 1.73 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
const argv = require('yargs-parser')(process.argv.slice(2));
const merge = require('webpack-merge');
const { resolve, join, basename } = require("path");
const _mode = argv.mode || "development";
let _mergeConfig = "";
if(argv.env == "sever"){
_mergeConfig = require(`./config/webpack.server.js`);
}else{
_mergeConfig = require(`./config/webpack.${_mode}.js`);
}
const _modeflag = (_mode == "production" ? true : false);
const { VueLoaderPlugin } = require('vue-loader')
let _plugins = [new VueLoaderPlugin()];
let webpackConfig = {
module: {
rules: [{
test: /\.vue$/,
loader: 'vue-loader',
options: {
//extractCSS:true
}
}, {
test: /\.js$/,
loader: 'babel-loader'
}, {
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
}, {
test: /\.(png|jpg|gif|eot|woff|woff2|ttf|svg|otf)$/,
use: [{
loader: 'file-loader',
options: {
name: _modeflag ? "images/[name].[hash:5].[ext]" : "images/[name].[ext]"
}
}]
}]
},
watch: !_modeflag,
watchOptions: {
ignored: /node_modules/,
aggregateTimeout: 300,
poll: 1
},
optimization: {
},
output: {
path: join(__dirname, './dist/assets'),
publicPath: "/",
filename: "scripts/[name].bundle.js"
},
plugins: [
..._plugins,
],
resolve: {
modules: [
resolve(__dirname, 'node_modules'),
],
extensions: [".js", ".css", ".vue"]
}
};
module.exports = merge(webpackConfig, _mergeConfig);