-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
85 lines (81 loc) · 2.23 KB
/
webpack.config.js
File metadata and controls
85 lines (81 loc) · 2.23 KB
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
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const { VueLoaderPlugin } = require('vue-loader')
const { DefinePlugin } = require('webpack')
const AutoImport = require('unplugin-auto-import/webpack').default
const Components = require('unplugin-vue-components/webpack').default
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
const path = require('path')
module.exports = env => {
const webpackConfig = {
entry: './src/main/js/main.js',
output: {
path: path.join(__dirname, '/target/classes/web'),
filename: env.WEBPACK_SERVE ? '[name].js' : '[contenthash].[name].js'
},
resolve: {
extensions: ['.js', '.mjs', '.vue']
},
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader'
},
{
test: /\.m?js$/,
use: 'babel-loader',
exclude: /node_modules\/(?!quill)/
},
{
test: /\.css$/,
use: [env.WEBPACK_SERVE ? 'style-loader' : MiniCssExtractPlugin.loader, 'css-loader']
},
{
test: /\.(png|jpg|jpeg|gif|eot|ttf|woff|woff2|svg|svgz)(\?.+)?$/,
type: 'asset/resource'
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/main/resources-build/index.html',
favicon: 'src/main/resources-build/favicon.png'
}),
new MiniCssExtractPlugin({
filename: env.WEBPACK_SERVE ? '[name].css' : '[contenthash].[name].css'
}),
new VueLoaderPlugin(),
new DefinePlugin({
DEV: env.WEBPACK_SERVE,
__VUE_OPTIONS_API__: 'true',
__VUE_PROD_DEVTOOLS__: 'false',
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: 'false'
}),
AutoImport({
resolvers: [ElementPlusResolver()]
}),
Components({
resolvers: [ElementPlusResolver()]
})
],
stats: {
assets: false,
modules: false
},
performance: {
hints: false
}
}
if (env.WEBPACK_SERVE) {
webpackConfig.devServer = {
port: 8084,
proxy: [{
context: '/',
target: 'http://localhost:8080'
}],
open: true
}
}
return webpackConfig
}