From 58fa96a792b708b758456ea96e0a3fb61291cc12 Mon Sep 17 00:00:00 2001 From: capt-nemo429 Date: Sat, 29 Oct 2022 15:12:37 -0300 Subject: [PATCH] add svg loader --- loaders/svgLoader.js | 13 +++++++++++++ vue.config.js | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 loaders/svgLoader.js diff --git a/loaders/svgLoader.js b/loaders/svgLoader.js new file mode 100644 index 00000000..c31fb3cc --- /dev/null +++ b/loaders/svgLoader.js @@ -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 ``; +}; diff --git a/vue.config.js b/vue.config.js index 9c14b519..07b69376 100755 --- a/vue.config.js +++ b/vue.config.js @@ -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();