This repository has been archived by the owner on May 27, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
91 lines (85 loc) · 2.43 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
90
91
const path = require('path');
const vueConfig = require('./vue-loader.config');
const webpack = require('webpack');
const { VueLoaderPlugin } = require('vue-loader');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: '#source-map',
entry: {
app: './src/app.js',
vendor: ['vue', 'vue-router', 'vuex', 'vuex-router-sync', 'axios']
},
resolve: {
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
extensions: ['.js', '.vue'],
alias: {
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components')
}
},
output: {
path: path.resolve(__dirname, 'dist'),
publicPath: '',
filename: 'client-bundle.[chunkhash].js'
},
optimization: {
runtimeChunk: true,
splitChunks: {
cacheGroups: {
commons: {
chunks: 'initial',
name: 'vendor',
test: 'vendor',
enforce: true,
minChunks: 2
}
}
}
},
plugins: [
new VueLoaderPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
'process.env.VUE_ENV': '"client"'
}),
new HtmlWebpackPlugin({
templateParameters: (compilation, assets, options) => ({
webpack: compilation.getStats().toJson(),
compilation: compilation,
webpack: compilation.getStats().toJson(),
webpackConfig: compilation.options,
htmlWebpackPlugin: {
files: assets,
options: options
}
}),
template: 'src/index.template.html'
})
],
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: { }
},
{
test: /\.css$/,
use: [ 'vue-style-loader','css-loader' ]
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
}
}