Vuepress: Unable to override default SVG loader

Created on 21 May 2018  路  2Comments  路  Source: vuejs/vuepress

I'm currently unable to use vue-svg-loader to load svgs in my .vue files.

I assume this is because vuepress uses file-loader to load svgs. (see : createBaseConfig.js#L150).

Is there a way to override the default vuepress svg loader?

I've tried:

config.js:

chainWebpack: config => {
    config.module
      .rule('svg')
      .test(/\.svg$/)
      .use('vue-svg-loader')
        .loader('vue-svg-loader')
        .end()
}

Most helpful comment

You need to remove the default rule first:

config.module.rules.delete('svg')
config.module
  .rule('svg')
    .test(/\.svg$/)
    .use('vue-svg-loader')
      .loader('vue-svg-loader')
      .end()

All 2 comments

You need to remove the default rule first:

config.module.rules.delete('svg')
config.module
  .rule('svg')
    .test(/\.svg$/)
    .use('vue-svg-loader')
      .loader('vue-svg-loader')
      .end()

Thank you worked perfectly!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

herrbischoff picture herrbischoff  路  3Comments

kid1412621 picture kid1412621  路  3Comments

higuoxing picture higuoxing  路  3Comments

ynnelson picture ynnelson  路  3Comments

alinnert picture alinnert  路  3Comments