-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
69 lines (65 loc) · 1.65 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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
module.exports = (env = {}) => {
const webpackConfig = {
entry: './src/main/js/main.js',
output: {
path: __dirname + '/src/main/resources/web',
filename: env.dev ? '[name].js' : '[chunkhash].[name].js'
},
resolve: {
extensions: [".js", ".vue"],
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader'
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.css$/,
loader: [env.dev ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
loader: 'file-loader'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/main/resources/index.html',
favicon: 'src/main/resources/favicon.png'
}),
new MiniCssExtractPlugin({
filename: env.dev ? '[name].css' : '[contenthash].[name].css'
}),
new CleanWebpackPlugin(),
new VueLoaderPlugin()
],
stats: {
entrypoints: false,
children: false,
assetsSort: 'chunks'
},
performance: {
hints: false
}
}
if (env.dev) {
webpackConfig.devServer = {
port: 8084,
proxy: {'/': 'http://localhost:8080'},
noInfo: true,
open: true
}
}
return webpackConfig
}