Sage 9 build:production issue - UglifyJs Unexpected token: operator (>) [scripts/main_6cab658f.js:12786,272]

Hey there,
I was wondering if anyone could point me in the right direction.

I’m building my assets and they compile fine with

yarn run build

However, when I compile with build:production, I receive the following error

yarn run build:production
yarn run v1.5.1
$ webpack --progress -p --config resources/assets/build/webpack.config.js
 94% asset optimization                                                               

 ERROR  Failed to compile with 1 errors                                                                         18:32:54

 error  

scripts/main_6cab658f.js from UglifyJs
Unexpected token: operator (>) [scripts/main_6cab658f.js:12786,272]

 27 assets
error An unexpected error occurred: "Command failed.
Exit code: 2
Command: sh
Arguments: -c webpack --progress -p --config resources/assets/build/webpack.config.js
Directory: /var/www/fliteboard/wp-content/themes/fliteboard
Output:
".
info If you think this is a bug, please open a bug report with the information provided in "/var/www/fliteboard/wp-content/themes/fliteboard/yarn-error.log".

I’ve attached my yarn-error.log file

Any ideas would be much appreciated!

Hi @BeyondLimts99 - have you looked around outside of the Roots discourse to see if anyone else has encountered this with UglifyJS and what the underlying cause was?

Another thing you’ll want to do is track down the original line of your script that it’s choking on. What is at line 12786, column 272 of scripts/main_6cab658f.js, and what does that correspond to in your unprocessed JS?

– Matt

Hello folks,

@mmirus, I got a similar error from Uglify when I use the command for production.
Maybe my JS isn’t transpiled correctly.

yarn build:production
yarn run v1.5.1
$ webpack --progress -p --config resources/assets/build/webpack.config.js
 94% asset optimization                                                               

 ERROR  Failed to compile with 1 errors                                                                                                                       12:29:21

 error  

scripts/main_3ac69daa.js from UglifyJs
Unexpected token: keyword (const) [scripts/main_3ac69daa.js:218,9]
                                                                                                                                                3 assets              
error An unexpected error occurred: "Command failed.
Exit code: 2
Command: sh
Arguments: -c webpack --progress -p --config resources/assets/build/webpack.config.js

Nevermind. I had a library which wasn’t transpiled. I replaced it by the build version and the problem is gone ! Sorry for the inconvenience.