Skip to content

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

Open
@ChangxueYu

Description

@ChangxueYu

直接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: './',

Activity

bingegege

bingegege commented on Jun 2, 2020

@bingegege

感谢

Weinbery

Weinbery commented on May 21, 2021

@Weinbery

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

lushanglehuozz commented on Apr 18, 2022

@lushanglehuozz

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Weinbery@bingegege@ChangxueYu@lushanglehuozz

        Issue actions

          【解决方式】npm run build报错问题,html路径错误问题 · Issue #168 · bailicangdu/vue2-manage