-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
121 lines (114 loc) · 2.8 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
const path = require('path')
const { VueLoaderPlugin } = require('vue-loader')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin')
module.exports = (env, argv) => ({
entry: './ui',
resolve: {
extensions: ['.js', '.vue']
},
output: {
filename: '[name].[contenthash].js',
path: path.resolve(__dirname, 'dist/static'),
publicPath: '/static/'
},
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader'
},
{
test: /\.js$/,
exclude: /node_modules/,
use: 'babel-loader'
},
{
test: /\.css$/,
use: [
argv.mode === 'development' ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [require('autoprefixer')]
}
}
}
]
},
{
test: /\.scss$/,
use: [
argv.mode === 'development' ? 'vue-style-loader' : MiniCssExtractPlugin.loader,
{
loader: 'css-loader',
options: {
// Disable url() resolving for fonts. These should be preloaded and cached
// long-term under /static/fonts/.
url: false
}
},
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [require('autoprefixer')]
}
}
},
'sass-loader'
]
},
{
test: /\.svg$/,
use: 'vue-svg-loader'
},
{
// Embed images as data URIs
test: /\.(png|jpg|gif|ico)$/,
type: 'asset/inline'
},
{
test: /\.html$/,
use: {
loader: 'html-loader',
options: {
// Disable attribute processing; preserve URLs as-is in index.html
sources: false
}
}
}
]
},
plugins: [
new VueLoaderPlugin(),
new HtmlWebpackPlugin({
template: 'ui/assets/index.html',
filename: path.resolve(__dirname, 'dist/index.html')
}),
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, 'public')
}
]),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css'
})
],
optimization: {
moduleIds: 'named',
minimizer: [
new TerserPlugin(),
new CssMinimizerPlugin()
]
},
devServer: {
historyApiFallback: true,
contentBase: path.resolve(__dirname, 'public')
}
})