svg-sprite-loader超级简单
const { defineConfig } = require("@vue/cli-service");
const { compile } = require("sass");
const path = require("path");
module.exports = defineConfig({
transpileDependencies: true,
devServer: {
open: true,
// compress: true,
// disableHostCheck: true,
},
chainWebpack: (config) => {
config.resolve.alias
.set("@", resolve("src"))
.set("assets", resolve("public/assets"));
config.module.rule("svg").exclude.add(resolve("public/assets/icon/")).end();
config.module
.rule("svg-sprite-loader")
.test(/\.svg$/)
.include.add(resolve("public/assets/"))
.end()
.use("svg-sprite-loader")
.loader("svg-sprite-loader")
.options({
symbolId: "icon-[name]",
})
.end();
},
});
function resolve(dir) {
return path.join(__dirname, dir);
}