Skip to content

Commit

Permalink
add svg loader
Browse files Browse the repository at this point in the history
  • Loading branch information
capt-nemo429 committed Oct 29, 2022
1 parent 67adf90 commit 58fa96a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions loaders/svgLoader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const { optimize } = require("svgo");

module.exports = function inlineSvgLoader(svg) {
const { svgo: svgoConfig } = this.getOptions() || {};
if (svgoConfig !== false) {
({ data: svg } = optimize(svg, {
path: this.resourcePath,
...svgoConfig
}));
}

return `<template>${svg}</template>`;
};
4 changes: 2 additions & 2 deletions vue.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ module.exports = defineConfig({
.use("vue-loader")
.loader("vue-loader")
.end()
.use("vue-svg-loader")
.loader("vue-svg-loader")
.use("inline-svg-loader")
.loader("./loaders/svgLoader.js")
.end();

config.plugin("windicss").use(new WindiCSSWebpackPlugin()).end();
Expand Down

0 comments on commit 58fa96a

Please sign in to comment.