-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
89 lines (87 loc) · 2.35 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
85
86
87
88
89
const path = require('path');
const webpack = require('webpack');
const VueLoaderPlugin = require('vue-loader/lib/plugin');
const TerserPlugin = require('terser-webpack-plugin');
const config = require('./server/config/environment');
module.exports = {
mode: config.env,
entry: {
app: (() => {
const appEntry = [];
if (process.env.NODE_ENV !== 'production') {
appEntry.push(path.resolve('client/entries/dev-client.js'));
}
return appEntry.concat(path.resolve('client/entries/main.js'));
})()
},
output: {
path: path.resolve('dist'),
publicPath: '/assets/',
filename: '[name].js',
chunkFilename: '[name].[chunkhash].js'
},
module: {
rules: [{
test: /\.vue$/,
loader: 'vue-loader'
}, {
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
}, {
test: /\.css$/,
use: ['vue-style-loader', 'css-loader']
}, {
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: 'img/[name].[hash:7].[ext]'
}
}, {
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: 'fonts/[name].[hash:7].[ext]'
}
}]
},
resolve: {
alias: {
vue: 'vue/dist/vue.common.js',
'vue-i18n': 'vue-i18n/dist/vue-i18n.common.js',
'vue-router': 'vue-router/dist/vue-router.common.js',
'vuex': 'vuex/dist/vuex.js',
moment: 'moment/moment.js',
'../moment': 'moment/moment.js',
semantic: path.resolve('client/semantic/dist/semantic.js')
}
},
plugins: [
new VueLoaderPlugin(),
new webpack.ProvidePlugin({ jQuery: 'jquery' }),
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin()
]
};
if (process.env.NODE_ENV === 'production') {
module.exports.optimization = module.exports.optimization || {};
module.exports.optimization.minimizer= [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
];
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
]);
} else {
module.exports.devtool = 'cheap-module-eval-source-map';
}