Webpack-构建中的.babelrc返回意外令牌:punc«)»?

时间:2019-07-25 19:09:32

标签: webpack babel package.json webpack-4

由于某种原因,我无法弄清楚为什么使用Webpack在生产模式下构建网站失败。当我注释该文件内部的所有内容时,我都有一个文件“ default.js”。

此错误是什么意思?这非常令人困惑,我无法调试。

谢谢!

Error:

 ERROR  Failed to compile with 1 errors                                                                                                                                                            9:05:19 PM

 error  

    js/prestigexotics.min.d871026bec97bc89f29d.js from UglifyJs
    Unexpected token: punc «)» [js/prestigexotics.min.d871026bec97bc89f29d.js:17,2]

    error Command failed with exit code 2.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    Ninos-iMac:WP-STARTER-V3 nino$ 

我的JS文件:

(() => {
    // Do not remove this console log. It serves as a reminder to build in production mode.
    // Building in production mode removes all console, alert and debug statements.
    // NM.
    console.log(
        '%c Running main script in development mode.',
        'color: #bada55; font-size: 12px; font-weight: 700'
    );

    // Add class top HTML tag if a mobile device is detected.
    const primaryHTML = document.querySelector('html');

    if (
        /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
            navigator.userAgent
        )
    ) {
        primaryHTML.classList.add('touchdevice');
    }
})();

.babelrc:

{
    "presets": [
        [
            "@babel/preset-env",
            {
                "useBuiltIns": "usage",
                "corejs": 3
            }
        ]
    ]
}

package.json:

"dependencies": {
    "@babel/core": "^7.5.5",
    "@babel/preset-env": "^7.5.5",
    "@babel/polyfill": "^7.4.4",
    "babel-loader": "^8.0.6",
    "babel-eslint": "10.0.2",
    "core-js": "^3.1.4",
    "autoprefixer": "^9.6.1",
    "browser-sync": "^2.26.7",
    "browser-sync-webpack-plugin": "^2.2.2",
    "browserslist": "^4.6.6",
    "checkenv": "^1.2.2",
    "clean-terminal-webpack-plugin": "^2.0.4",
    "clean-webpack-plugin": "^3.0.0",
    "copy-webpack-plugin": "^5.0.3",
    "cross-env": "^5.2.0",
    "css-loader": "3.1.0",
    "eslint": "^6.1.0",
    "eslint-loader": "2.2.1",
    "extra-watch-webpack-plugin": "^1.0.3",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "happypack": "^5.0.1",
    "hard-source-webpack-plugin": "^0.13.1",
    "imagemin-webpack-plugin": "^2.4.0",
    "mini-css-extract-plugin": "^0.8.0",
    "node-sass": "^4.12.0",
    "sass-loader": "^7.0.3",
    "source-map-loader": "^0.2.3",
    "stylelint": "^10.0.1",
    "stylelint-scss": "^3.6.1",
    "stylelint-use-nesting": "^1.2.1",
    "stylelint-webpack-plugin": "^0.10.5",
    "stylelint-z-index-value-constraint": "^1.1.0",
    "uglifyjs-webpack-plugin": "^2.1.1",
    "webpack": "4.37.0",
    "webpack-build-notifier": "^1.0.3",
    "webpack-bundle-analyzer": "^3.3.2",
    "webpack-config-utils": "^2.3.1",
    "webpack-manifest-plugin": "^2.0.4",
    "webpack-plugin-hash-output": "^3.2.0"
},
"devDependencies": {
    "webpack-cli": "^3.3.6"
}

1 个答案:

答案 0 :(得分:0)

@Grzegorz T.解决了它。重复项可以删除。抱歉!