Skip to content
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

createAPI时获取不到component name名称 #14

Open
yinminhe opened this issue Jul 25, 2019 · 2 comments
Open

createAPI时获取不到component name名称 #14

yinminhe opened this issue Jul 25, 2019 · 2 comments

Comments

@yinminhe
Copy link

yinminhe commented Jul 25, 2019

用ts 通过装饰器@component创建的组件无法定义名称,打包编译后组件类名被压缩,导致执行createAPI时获取不到component name名称

是否能在执行createAPI时定义自定义组件名称

Component must have name while using create-api!

@xiaohaiH
Copy link

强烈建议在 createAPI 执行时, 支持传入函数或字符串来定义组件名称
前面是用这个插件terser-webpack-plugin解决的, 但是最近这个插件自动升级后, 影响到 photoswipe 的使用了(无法打开大图预览)

@KevisLuo
Copy link

目前可以通过修改webpack的(terser)配置解决这个问题,已防止打包编译时组件名称被修改。
由于组件最终是被编译成function,所以要设置keep_fnames为true,防止丢弃或破坏函数名。

  // vue.config.js
  chainWebpack: config => {
    config.optimization.minimizer('terser').tap(args => {
      args[0].terserOptions.keep_fnames = true
      return args
    })
  }

上面是 Vue CLI v4的配置,v3的配置可参考https://cli.vuejs.org/migrating-from-v3/#vue-cli-service

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