1

In our project we are using vue-svg-loader (latest version) with the following configuration file vue.config.js:

  const svgRule = config.module.rule('svg')
  svgRule.uses.clear()
  svgRule
    .use('babel-loader')
    .loader('babel-loader')
    .end()
    .use('vue-svg-loader')
    .loader('vue-svg-loader')
    .options({
      svgo: {
        plugins: [{ removeViewBox: false }]
      }
    })

unfortunately after upgrading our @vue/cli-service 5.0.4 from @vue/cli-service 3.4.0 everything works but our svgs, which are not loading any more with the following error:

[Vue warn]: Invalid Component definition: /public/img/island-small.3fa8ec4c.svg found in <ZnLogin> at src/pages/login/login.vue

I tried playing with the versions, variety of configurations (mostly the default one) and nothing seems to work. I do wish to keep the current usage method:

<template>
  <VueLogo/>
</template>
<script>
import VueLogo from './public/vue.svg';

export default {
  name: 'Example',
  components: {
    VueLogo,
  },
};
</script>
  

any idea?

1 Answer 1

2

Check out this issue.

https://github.com/visualfanatic/vue-svg-loader/issues/185

Changing the vue configuration worked for me.

// vue.config.js

module.exports = {
  chainWebpack: (config) => {
    config.module.rules.delete("svg");
    config.module.rule("svg")
      .test(/\.(svg)(\?.*)?$/)
      .use("babel-loader")
      .loader("babel-loader")
      .end()
      .use("vue-svg-loader")
      .loader("vue-svg-loader");
  },
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.