Skip to content

@vue/cli3 use loader on chrome 55,56,57 Unexpected token #74

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

Closed
sendya opened this issue Feb 27, 2019 · 4 comments
Closed

@vue/cli3 use loader on chrome 55,56,57 Unexpected token #74

sendya opened this issue Feb 27, 2019 · 4 comments

Comments

@sendya
Copy link

sendya commented Feb 27, 2019

use vue-svg-loader error on inline mode
But the latest version of the browser not go wrong (chrome 72)

vue.config.js (chainWebpack)

  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', resolve('src'))

    const svgRule = config.module.rule('svg')
    svgRule.uses.clear()
    svgRule.oneOf('inline')
      .resourceQuery(/inline/)
      .use('vue-svg-loader')
      .loader('vue-svg-loader')
      .end()
      .end()
      .oneOf('external')
      .use('file-loader')
      .loader('file-loader')
      .options({
        name: 'assets/[name].[hash:8].[ext]'
      })
  }

And use svg:

// path to your '*.svg?inline' file.
import bxAnaalyse from '@/assets/icons/bx-analyse.svg?inline'
<template>
  <div>
    <LogoSvg />
  </div>
</template>
<script>
import LogoSvg from '@/assets/logo.svg?inline'

console.log(LogoSvg)

export default {
  name: 'Logo',
  components: {
    LogoSvg
  },
  data () {
    return {
    }
  }
}
</script>

Uncaught SyntaxError: Unexpected token ... at Object../src/assets/icons/bx-analyse.svg?inline (app.js:13833) at webpack_require (app.js:767) at fn (app.js:130) at eval (webpack-internal:///./src/core/icons.js:2) at Module../src/core/icons.js (app.js:14756) at webpack_require (app.js:767) at fn (app.js:130) at eval (webpack-internal:///./src/config/router.config.js:5) at Module../src/config/router.config.js (app.js:14732) at webpack_require (app.js:767)

@damianstasik
Copy link
Owner

@sendya could you share your SVG file?

@sendya
Copy link
Author

sendya commented Feb 28, 2019

@sendya could you share your SVG file?

Downloaded from iconfont.cn

https://static-2.loacg.com/open/static/github/a/bx-analyse.svg
or
https://static-2.loacg.com/open/static/github/a/logo.svg

source:

<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1551058675966" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7872" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><defs><style type="text/css"></style></defs><path d="M85.333333 512h85.333334a340.736 340.736 0 0 1 99.712-241.621333 337.493333 337.493333 0 0 1 108.458666-72.96 346.453333 346.453333 0 0 1 261.546667-1.749334A106.154667 106.154667 0 0 0 746.666667 298.666667C805.802667 298.666667 853.333333 251.136 853.333333 192S805.802667 85.333333 746.666667 85.333333c-29.397333 0-55.978667 11.776-75.221334 30.933334-103.722667-41.514667-222.848-40.874667-325.76 2.517333a423.594667 423.594667 0 0 0-135.68 91.264 423.253333 423.253333 0 0 0-91.306666 135.637333A426.88 426.88 0 0 0 85.333333 512z m741.248 133.205333c-17.109333 40.618667-41.685333 77.141333-72.96 108.416s-67.797333 55.850667-108.458666 72.96a346.453333 346.453333 0 0 1-261.546667 1.749334A106.154667 106.154667 0 0 0 277.333333 725.333333C218.197333 725.333333 170.666667 772.864 170.666667 832S218.197333 938.666667 277.333333 938.666667c29.397333 0 55.978667-11.776 75.221334-30.933334A425.173333 425.173333 0 0 0 512 938.666667a425.941333 425.941333 0 0 0 393.258667-260.352A426.325333 426.325333 0 0 0 938.666667 512h-85.333334a341.034667 341.034667 0 0 1-26.752 133.205333z" p-id="7873"></path><path d="M512 318.378667c-106.752 0-193.621333 86.869333-193.621333 193.621333S405.248 705.621333 512 705.621333s193.621333-86.869333 193.621333-193.621333S618.752 318.378667 512 318.378667z m0 301.909333c-59.690667 0-108.288-48.597333-108.288-108.288S452.309333 403.712 512 403.712s108.288 48.597333 108.288 108.288-48.597333 108.288-108.288 108.288z" p-id="7874"></path></svg>

@supermonkeyz
Copy link

supermonkeyz commented Jun 26, 2019

got same error Unexpected token ...

break with this compiled code

const {
  class: classNames,
  staticClass,
  style,
  staticStyle,
  attrs = {},
  ...rest 
} = data;

something wrong with babel config?

@damianstasik
Copy link
Owner

@supermonkeyz please check out the updated readme (missing babel-loader in webpack config).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants