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

Webpack error #29

Open
Rudloff opened this issue Oct 12, 2019 · 2 comments
Open

Webpack error #29

Rudloff opened this issue Oct 12, 2019 · 2 comments

Comments

@Rudloff
Copy link
Contributor

Rudloff commented Oct 12, 2019

When calling yarn build on dd1821e, it fails with this error:

$ webpack --progress
Hash: a06a16c0547e736a599f                                                         
Version: webpack 3.12.0
Time: 884ms
                      Asset       Size  Chunks             Chunk Names
    OverPassLayer.bundle.js     218 kB       0  [emitted]  OverPassLayer
          OverPassLayer.css  429 bytes       0  [emitted]  OverPassLayer
OverPassLayer.bundle.js.map     263 kB       0  [emitted]  OverPassLayer
      OverPassLayer.css.map   94 bytes       0  [emitted]  OverPassLayer
   [1] ./OverPassLayer.js 10.9 kB {0} [built]
   [3] ./OverPassLayer.css 41 bytes {0} [built]
   [4] ./MinZoomIndicator.js 1.9 kB {0} [built]
    + 3 hidden modules

ERROR in OverPassLayer.bundle.js from UglifyJs
Unexpected token: punc (() [OverPassLayer.bundle.js:102,17]
Child extract-text-webpack-plugin ../node_modules/extract-text-webpack-plugin/dist ../node_modules/css-loader/index.js!../node_modules/postcss-loader/lib/index.js!OverPassLayer.css:
       [0] ../node_modules/css-loader!../node_modules/postcss-loader/lib!./OverPassLayer.css 556 bytes {0} [built]
        + 1 hidden module

Edit: I also tried using using npm instead of yarn, but I get the same error.

@GuillaumeAmat
Copy link
Owner

What node version are you using? There is a .nvmrc file with version 8 for the record.

@Rudloff
Copy link
Contributor Author

Rudloff commented Oct 13, 2019

I am using Node 10.15.2.

It looks like webpack 3.12.0 brings uglifyjs-webpack-plugin 0.4.6, which does not like ES6.
Requiring uglifyjs-webpack-plugin 1.3.0 explicitely fixes the issue for me:

diff --git a/package.json b/package.json
index f56b462..508f33d 100644
--- a/package.json
+++ b/package.json
@@ -60,6 +60,7 @@
     "lint-staged": "^4.2.3",
     "postcss-loader": "^2.0.7",
     "prettier": "^1.7.4",
-    "webpack": "^3.6.0"
+    "webpack": "^3.6.0",
+    "uglifyjs-webpack-plugin": "^1.0.0"
   }
 }
diff --git a/webpack.config.js b/webpack.config.js
index e3eca58..a689f1a 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -2,18 +2,21 @@ const webpack = require('webpack');
 const path = require('path');
 const ExtractTextPlugin = require('extract-text-webpack-plugin');
 const extractCSS = new ExtractTextPlugin('OverPassLayer.css');
+const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
 
 const plugins = [extractCSS];
 
 plugins.push(
-  new webpack.optimize.UglifyJsPlugin({
-    minimize: true,
-    mangle: true,
-    output: {
-      comments: false
-    },
-    compress: {
-      warnings: false
+  new UglifyJSPlugin({
+    uglifyOptions: {
+      minimize: true,
+      mangle: true,
+      output: {
+        comments: false
+      },
+      compress: {
+        warnings: false
+      }
     }
   })
 );

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

2 participants