question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

npm run production fail to uglify

See original GitHub issue

Hi all,

  • Laravel Mix Version: 0.11.4
  • Node Version : 6.10.3
  • NPM Version : 4.6.1
  • OS: OSX 10.11.6

Description: when run : npm run production it faill with error on uglify

(Unexpected token: punc (() … )

It seam to be a babel error but can’t resolve that.

I’ have add an .babelrc with { 'presets': [ ['es2015', { 'modules': false }] ] }

but it didnt resolve the pbm.

Any one have some way to point me to solution ?

fbm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

17reactions
bungcipcommented, May 20, 2017

I also has same issue with uglify. My current workaround is to use Babili. my webpack.mix.js

const { mix } = require('laravel-mix');
const BabiliPlugin = require('babili-webpack-plugin');
const webpack = require('webpack');
const webpackConfig = {
 ...
};

...

if (mix.config.inProduction) {
    webpackConfig.plugins.push(new BabiliPlugin());

    mix.options({
        uglify: false
    });
    mix.disableNotifications();
    //    mix.version();
    
} else {
    mix.sourceMaps();
}

mix.webpackConfig(webpackConfig);

6reactions
jbrunicommented, Jun 4, 2017

I just had this Unexpected token: punc issue, and this is how I resolved it, @fbmfbm:

My .babelrc was:

{
  "plugins": ["transform-object-rest-spread"]
}

I have changed it to:

{
  "presets": [
    ["env", {
      "modules": false,
      "targets": {
          "browsers": ["> 2%"],
          "uglify": true
      }
    }]
  ],
  "plugins": ["transform-object-rest-spread"]
}

The fact is: when we use a custom .babelrc file, the default Laravel Mix configuration for babel is lost.

So, I have prepended the lost default configuration to my custom .babelrc configuration, and got it working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

npm run production fail to uglify · Issue #823 - GitHub
Hi all, Laravel Mix Version: 0.11.4 Node Version : 6.10.3 NPM Version : 4.6.1 OS: OSX 10.11.6 Description: when run : npm run...
Read more >
npm run build prod not working with UglifyJs - Stack Overflow
I am implementing a project with vue js. When I perform build production with the npm run build command, ...
Read more >
Errors when running npm run production - Laracasts
Hi I am completely new to npm and I am already getting a BUNCH of errors when I run npm production. I don't...
Read more >
Troubleshooting - Create React App
npm run build fails to minify​. Before react-scripts@2.0.0 , this problem was caused by third party node_modules using modern JavaScript ...
Read more >
uglify-js - npm
JavaScript parser, mangler/compressor and beautifier toolkit. Latest version: 3.17.4, last published: 2 months ago. Start using uglify-js in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found