Vue-svg-loader: svg-to-vue dependency using spread syntax which doesn't compiled

Created on 10 Apr 2019  Â·  10Comments  Â·  Source: visualfanatic/vue-svg-loader

I got Uncaught SyntaxError: Unexpected token ... in some browsers, like Chrome58, is it a way to use a compatible version?

Most helpful comment

In vue.config.js fix like this.

const svgRule = config.module.rule('svg');
    svgRule.uses.clear();
    svgRule
      .use('babel-loader')
      .loader('babel-loader')
      .end()
      .use('vue-svg-loader')
      .loader('vue-svg-loader')
      .options({
        svgo: {
          plugins: [
            { removeDoctype: true },
            { removeComments: true },
            { removeViewBox: false }
          ],
          removeViewBox: false,
        },
      })
      .end()

All 10 comments

same problem

Same problem

+1

+1 😿,害我找了好久

I just fork the loader, update code manually, remove the unwanted syntax, or use another loader which I found it pass the code to vue-loader for further compile.

It can be fixed by configuring vue.config.js file correctly, I will paste my solution code later.

In vue.config.js fix like this.

const svgRule = config.module.rule('svg');
    svgRule.uses.clear();
    svgRule
      .use('babel-loader')
      .loader('babel-loader')
      .end()
      .use('vue-svg-loader')
      .loader('vue-svg-loader')
      .options({
        svgo: {
          plugins: [
            { removeDoctype: true },
            { removeComments: true },
            { removeViewBox: false }
          ],
          removeViewBox: false,
        },
      })
      .end()

Thx!
btw what does svgo mean

@GodofHope svgo is an svg optimizer. https://github.com/svg/svgo

I think @youcanping's config should really be very prominent in the docs, so I added it to the README, see pull request https://github.com/visualfanatic/vue-svg-loader/pull/93

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jdfx picture jdfx  Â·  7Comments

santigarcor picture santigarcor  Â·  8Comments

psulkava picture psulkava  Â·  3Comments

dsbert picture dsbert  Â·  6Comments

Peppe87 picture Peppe87  Â·  4Comments