-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nuxtjs + Vue-svg-loader #1332
Comments
Hi, @danciupuliga. I think you need to remove
The second rule seems to be overwriting the first one. |
@danciupuliga, another thought: Are you using nuxt 1.0.0-rc3 or later? If so, maybe the problem is that you are applying those loader rules on: build: {
loaders: [ ... ]
}, If you check RC3 breaking changes, you'll notice that the " build: {
extend(config, ctx) {
// Find default SVG rule
let imgRuleIndex = null;
for (let i = 0; i < config.module.rules.length; i += 1) {
if (config.module.rules[i].test.toString().match('gif')) {
imgRuleIndex = i;
break;
}
}
const imgRule = config.module.rules[imgRuleIndex];
// Overwrite the default images rule, removing SVG from it
config.module.rules[imgRuleIndex] = {
test: /\.(png|jpe?g|gif)$/,
loader: imgRule.loader,
query: imgRule.query,
};
// Now, add your own SVG rule
config.module.rules.push({
test: /\.svg/,
loader: <YOUR-FAVORITE-LOADER>, // 'vue-svg-loader', 'svg-sprite-loader', 'svgo-loader'... you choose. ;)
});
},
}, |
Or you can try this shorter variant: build: {
extend (config) {
const urlLoader = config.module.rules.find((rule) => rule.loader === 'url-loader')
urlLoader.test = /\.(png|jpe?g|gif)$/
config.module.rules.push({
test: /\.svg$/,
loader: 'svg-inline-loader',
exclude: /node_modules/
})
}
} |
thanks @KonstantinVlasov that worked! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
I am trying to integrate https://www.npmjs.com/package/vue-svg-loader for loading SVG icons inline as vue components.
I have the following in my nuxt.config file:
It seems that the svg files are still being converted to base64 by the url-loader even though I have excluded the path to the svg directory.
Is there a different way to overwrite the url-loader to ignore svg files?
The text was updated successfully, but these errors were encountered: