1
This commit is contained in:
@@ -17,13 +17,27 @@ module.exports = {
|
||||
config.resolve.alias.set("@", resolve("src"));
|
||||
config.resolve.alias.set("_c", resolve("src/components"));
|
||||
|
||||
// 正确处理 SVG 文件
|
||||
config.module.rule('svg')
|
||||
.test(/\.svg$/)
|
||||
.use('file-loader')
|
||||
.loader('file-loader')
|
||||
.options({
|
||||
name: 'assets/svg/[name].[hash:8].[ext]'
|
||||
});
|
||||
|
||||
config.module.rule('images').test(/\.(png|jpe?g|gif)(\?.*)?$/).use('url-loader').loader('url-loader').options({
|
||||
limit: 10000,
|
||||
esModule: false,
|
||||
outputPath: "images/"
|
||||
})
|
||||
// 处理图片文件(排除 SVG)
|
||||
config.module.rule('images')
|
||||
.test(/\.(png|jpe?g|gif)(\?.*)?$/)
|
||||
.use('url-loader')
|
||||
.loader('url-loader')
|
||||
.options({
|
||||
limit: 10000,
|
||||
esModule: false,
|
||||
outputPath: "images/"
|
||||
});
|
||||
|
||||
// 图片压缩(仅对 PNG、JPG、GIF)
|
||||
config.module.rule('images')
|
||||
.test(/\.(png|jpe?g|gif)(\?.*)?$/)
|
||||
.use('image-webpack-loader')
|
||||
@@ -47,13 +61,7 @@ module.exports = {
|
||||
webp: {
|
||||
quality: 75
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
configureWebpack: {
|
||||
@@ -61,6 +69,28 @@ module.exports = {
|
||||
filename: "js/[hash].js",
|
||||
},
|
||||
},
|
||||
|
||||
// PostCSS 配置
|
||||
css: {
|
||||
loaderOptions: {
|
||||
postcss: {
|
||||
postcssOptions: {
|
||||
plugins: [
|
||||
require('autoprefixer'),
|
||||
require('postcss-pxtorem')({
|
||||
rootValue: 16,
|
||||
propList: ['*'],
|
||||
selectorBlackList: [],
|
||||
replace: true,
|
||||
mediaQuery: false,
|
||||
minPixelValue: 1,
|
||||
exclude: /node_modules/i
|
||||
})
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
// 设为false打包时不生成.map文件
|
||||
productionSourceMap: sourceMap,
|
||||
};
|
||||
Reference in New Issue
Block a user