我有這個規則,使用 vue inspect
/* config.module.rule('svg') */
{
test: /\.(svg)(\?.*)?$/,
type: 'asset/resource',
generator: {
filename: 'img/[name][ext]'
}
},
例如,我需要將檔案名更改為“[contenthash][ext]”,但我無法使用
module.exports = defineConfig({
chainWebpack: (config) => {
config.module.rule("svg").generator.filename = "[contenthash][ext]";
},
})
因為我不能設定發電機,
我可以使用重寫所有規則
module.exports = defineConfig({
configureWebpack: (config) => {
config.module.rules = [
{
test: /\.(svg)(\?.*)?$/,
use: [
{
loader: "svg-inline-loader",
options: {
name: "[contenthash].[ext]",
},
},
],
},
];
},
})
但我需要存在其他規則......那么我該如何更改 svg 的檔案名?
uj5u.com熱心網友回復:
嘗試這個:
chainWebpack: (config) => {
config.module.rule("svg")
.set('generator', {
filename: "[contenthash][ext]"
})
}
來源
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/366300.html
標籤:Vue.js 网络包 vue-cli vue-cli-5
