<tfoot id='efm0V'></tfoot>
      <bdo id='efm0V'></bdo><ul id='efm0V'></ul>
  1. <legend id='efm0V'><style id='efm0V'><dir id='efm0V'><q id='efm0V'></q></dir></style></legend>

    <small id='efm0V'></small><noframes id='efm0V'>

    <i id='efm0V'><tr id='efm0V'><dt id='efm0V'><q id='efm0V'><span id='efm0V'><b id='efm0V'><form id='efm0V'><ins id='efm0V'></ins><ul id='efm0V'></ul><sub id='efm0V'></sub></form><legend id='efm0V'></legend><bdo id='efm0V'><pre id='efm0V'><center id='efm0V'></center></pre></bdo></b><th id='efm0V'></th></span></q></dt></tr></i><div id='efm0V'><tfoot id='efm0V'></tfoot><dl id='efm0V'><fieldset id='efm0V'></fieldset></dl></div>

      Uglify SyntaxError: Unexpected token: punc ())

      时间:2023-05-28
        <tbody id='wPFco'></tbody>
    1. <legend id='wPFco'><style id='wPFco'><dir id='wPFco'><q id='wPFco'></q></dir></style></legend>

            <bdo id='wPFco'></bdo><ul id='wPFco'></ul>
            <i id='wPFco'><tr id='wPFco'><dt id='wPFco'><q id='wPFco'><span id='wPFco'><b id='wPFco'><form id='wPFco'><ins id='wPFco'></ins><ul id='wPFco'></ul><sub id='wPFco'></sub></form><legend id='wPFco'></legend><bdo id='wPFco'><pre id='wPFco'><center id='wPFco'></center></pre></bdo></b><th id='wPFco'></th></span></q></dt></tr></i><div id='wPFco'><tfoot id='wPFco'></tfoot><dl id='wPFco'><fieldset id='wPFco'></fieldset></dl></div>

                <tfoot id='wPFco'></tfoot>

                <small id='wPFco'></small><noframes id='wPFco'>

              • 本文介绍了Uglify SyntaxError: Unexpected token: punc ())的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我正在尝试使用 gulp 来缩小包含 JS 文件的文件夹.但是,其中一个文件存在上述错误,导致无法对其进行缩小.

                I am trying to use gulp in order to minify a folder containing JS files. However, one of the files has the above error, preventing it from being minified.

                我设法捕获并打印了错误,我在此处部分打印了该错误:

                I managed to catch and print the error, which I've partially printed here:

                JS_Parse_Error {
                 message: 'SyntaxError: Unexpected token: punc ())',
                 filename: 'ex.js',
                 line: 189,
                 col: 25,
                 pos: 6482,
                 stack: Error
                    at new JS_Parse_Error (eval at <anonymous> ... ) 
                 plugin: 'gulp-uglify',
                 fileName: '.../js/ex.js',
                 showStack: false
                }
                

                相关文件包含以下内容,已缩短:

                The file in question contains the following, shortened:

                function() {
                  ...
                  $.confirm({
                    buttons: {
                        confirm: function() {
                            $.post('/ajax-handler', {
                                    ...
                                })
                                .done( function(response) {
                                    var data = filterResponse(response);
                                    if (data['status'] == 'success') {
                                        sleep(1000).then(() => {
                                    *       ...
                                        });
                                        sleep(5000).then(() => {
                                            ...  
                                        });
                
                                    } else {
                                        console.log('Oops!');
                                    }
                                })
                                .fail( function(err, status, response) {
                                    ...
                            });
                        },
                        cancel: function() {}
                    }
                 });
                  ...
                }
                

                我在上面添加了*"以指示 JS_Parse_Error 列出的确切位置.

                I added the "*" above in order to indicate the exact position listed by JS_Parse_Error.

                推荐答案

                //更新

                来自评论~ @imolit

                切换回 uglify-js(uglify-es 已弃用,如果需要 uglify ES6 代码请使用 terser-webpack-plugin).

                 v2.0.0 (2018-09-14) - BREAKING CHANGES (link)

                Switch back to uglify-js (uglify-es is abandoned, if you need uglify ES6 code please use terser-webpack-plugin).

                <小时>

                我希望你能从这个适用于 webpack 的解决方案中得到启发.(以下链接)

                I hope you can get inspired by this solution which works with webpack. (link below)

                UglifyJS 有两个版本 - ES5ES6 (Harmony),在 git 上查看
                ES5 版本默认包含所有插件,但如果您明确安装 Harmony 版本,这些插件将使用它.

                There are two versions of UglifyJS - ES5 and ES6 (Harmony), see on git
                ES5 version comes by default with all the plugins, but if you install a Harmony version explicitly, those plugins will use it instead.

                package.json

                package.json

                "uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony"
                

                npm install --save uglify-js@github:mishoo/UglifyJS2#harmony
                
                yarn add git://github.com/mishoo/UglifyJS2#harmony --dev
                

                <小时>

                网页包

                要与 webpack 一起使用,还要安装 webpack 插件


                Webpack

                To use it with webpack install also the webpack plugin

                npm install uglifyjs-webpack-plugin --save-dev
                
                yarn add uglifyjs-webpack-plugin --dev
                

                然后导入手动安装的插件

                then import the manually installed plugin

                var UglifyJSPlugin = require('uglifyjs-webpack-plugin');
                

                并在代码中替换它

                -  new webpack.optimize.UglifyJsPlugin({ ... })
                +  new UglifyJSPlugin({ ... })
                

                <小时>

                有关更多 webpack 信息(安装/使用),请参阅 https://github.com/webpack-contrib/uglifyjs-webpack-plugin#install

                这篇关于Uglify SyntaxError: Unexpected token: punc ())的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:使用循环创建任务 [gulp] 下一篇:Visual Studio 任务运行程序“SyntaxError:在严格模式下

                相关文章

                最新文章

                  <small id='uk7gx'></small><noframes id='uk7gx'>

                    • <bdo id='uk7gx'></bdo><ul id='uk7gx'></ul>
                    <i id='uk7gx'><tr id='uk7gx'><dt id='uk7gx'><q id='uk7gx'><span id='uk7gx'><b id='uk7gx'><form id='uk7gx'><ins id='uk7gx'></ins><ul id='uk7gx'></ul><sub id='uk7gx'></sub></form><legend id='uk7gx'></legend><bdo id='uk7gx'><pre id='uk7gx'><center id='uk7gx'></center></pre></bdo></b><th id='uk7gx'></th></span></q></dt></tr></i><div id='uk7gx'><tfoot id='uk7gx'></tfoot><dl id='uk7gx'><fieldset id='uk7gx'></fieldset></dl></div>

                  1. <tfoot id='uk7gx'></tfoot>
                    <legend id='uk7gx'><style id='uk7gx'><dir id='uk7gx'><q id='uk7gx'></q></dir></style></legend>