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

【解决方式】npm run build报错问题,html路径错误问题 #168

Open
ChangxueYu opened this issue Apr 27, 2020 · 3 comments
Open

Comments

@ChangxueYu
Copy link

直接npm run build会报错如下:
ERROR in static/js/0.94510c9d26edb4b687ab.js from UglifyJs
Unexpected token: punc (() [./~/time-formater/lib/timeformater.js:21,0][static/js/0.94510c9d26edb4b687ab.js:41797,10]

主要问题是UglifyJs压缩代码的时候,无法压缩ES6的代码,要先用bable转化为ES5.
time-formater这个库是ES6的,并且没有被转化。
解决方式:
npm install --save--dev babel-preset-es2015@6.24.1
在webpack.base.conf下,把
include: [resolve('src'), resolve('test')] 修改为
include: [resolve('src'), resolve('test'),resolve('node_modules/time-formater')]

index.html引用js.css路径不对的问题,在config/index.js中
设置成assetsPublicPath: './',

@bingegege
Copy link

感谢

@Weinbery
Copy link

Weinbery commented May 21, 2021

time-formater打包错误的问题,按照以上方案仍然没有解决。请问还有其他地方需要注意的没?谢谢!
ERROR in static/js/0.a654f1e5aa8523826902.js from UglifyJs
Unexpected token: punc (() [./~/_time-formater@1.1.3@time-formater/lib/timeformater.js:21,0][static/js/0.a654f1e5aa8523826902.js:41766,10]

@lushanglehuozz
Copy link

time-formater打包错误的问题,按照以上方案我也没有解决。其他人有解决的吗?
image
image
image

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

4 participants