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:
- What is my mistake?
- How/where can/should I add new Webpack settings
- or modify/overwrite/delete existing ones
in a vue-cli (V3) project?
In webpack.base.conf.js add the following code under rule:
And remove the svg from the existing below rule:
Add the following into
vue.config.js
: