You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
extend(config: any){constsvgRule=config.module.rules.find((rule: any)=>rule.test.test('.svg'));svgRule.test=/\.(png|jpe?g|gif|webp)$/i;config.module.rules.push({test: /\.svg$/,oneOf: [{resourceQuery: /inline/,use: ['vue-loader','vue-svg-loader',],},// Add original url-loader config to resolve every other svg without inline querysvgRule.use[0],],});returnconfig;},
The text was updated successfully, but these errors were encountered:
I'm trying to get it to work in the reverse - I want to load the SVG inline by default and only load it externally when the resource query is passed in. So I thought I'd need to switch the rule order, as otherwise oneOf would always match the inline import pattern first:
constsvgRule=config.module.rule('svg')svgRule.uses.clear()svgRule.oneOf('external').resourceQuery('/external/').use('file-loader').loader('file-loader').options({name: 'assets/[name].[hash:8].[ext]'}).end().end().oneOf('inline').use('vue-loader')// or babel-loader on 0.16.0.loader('vue-loader').end().use('vue-svg-loader').loader('vue-svg-loader').end().end()
So I could do
import ComponentIcon from './svg/icon.svg' // Can be used as <component-icon />
import IconPath from './svg/icon.svg?external' // Can be used as <img:src="iconPath" />
But i still get back a Vue instance for both imports (with both 0.16.0 & 0.17.*) 🤔 @visualfanatic or @daniluk4000 do you spot anything wrong with my rules?
I will just leave it here for someone looking for usage in 0.17.x. It's almost the same, but without babel
Vue
Tested in Vue 2.x
Nuxt
The text was updated successfully, but these errors were encountered: