-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvue.config.js
41 lines (40 loc) · 1.19 KB
/
vue.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
const { defineConfig } = require('@vue/cli-service');
const path = require('path'); // 引入 path 模块
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
port: 8080,
open: true,
},
configureWebpack: {
module: {
rules: [
{
test: /\.(png|jpe?g|gif|webp)(\?.*)?$/i,
exclude: /node_modules/,
include: path.resolve('src'), // 使用 path.resolve() 解析路径
use: [
{
loader: 'url-loader',
options: {
esModule: false, // 不转换esm规范
name: 'img/[name].[hash:2].[ext]',
limit: 1024 * 12
}
},
{
loader: 'image-webpack-loader',
options: {
mozjpeg: { progressive: true, quality: 50 }, // 压缩JPEG图像
optipng: { enabled: true }, // 压缩PNG图像
pngquant: { quality: [0.5, 0.65], speed: 4 }, // 压缩PNG图像
// gifsicle: { interlaced: false }, // 压缩GIF图像
webp: { quality: 75 } // 压缩webp
}
}
]
}
]
}
}
});