If I want to use vue-svg-loader in an existing vue-cli application, I get the error message 
[Vue warn]: Invalid Component definition: /img/logout.b0c3dfb7.svg
Following Steps are already done:
1) Install vue-svg-loader as devDependency
2) Add Webpack Config in vue.config.js (root directory):
module.exports = {
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.svg$/,
          loader: 'vue-svg-loader', 
        },
      ],
    }      
  }
};
3) Import SVG and inject as Component
import Logout from '@/assets/img/icons/logout.svg';
export default {
    components: {
      Logout,
    },
...
}
4) Use it in the template (vuetify as UI-Framework)
<v-btn icon @click="logout()">
    <Logout class="icon" />
</v-btn>
3 Questions:
in a vue-cli (V3) project?
Add the following into vue.config.js:
module.exports = {
  chainWebpack: config => {
    config.module.rules.delete("svg");
  },
  configureWebpack: {
    module: {
      rules: [
        {
          test: /\.svg$/, 
          loader: 'vue-svg-loader', 
        },
      ],
    }      
  }
};
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With