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.

Minification failures after 1.0.0 upgrade

See original GitHub issue
  • Laravel Mix Version: 1.0.0
  • Node Version: v8.0.0
  • Yarn Version: 0.24.6
  • OS: macOS 10.12.5

Description:

After upgrading to Laravel Mix 1.0.0, I can no longer run a production build, as the minification fails citing an inability to find the file it’s trying to minify:

Whoops! We had trouble minifying "/themes/_shared/dist/enrolment.js". Perhaps you need to use mix.babel() instead?
/Users/gherman/Sites/whitireia/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:67
                throw e;
                ^

Error: ENOENT: no such file or directory, open '/themes/_shared/dist/enrolment.js'
    at Object.fs.openSync (fs.js:638:18)
    at Object.fs.readFileSync (fs.js:540:33)
    at addFile (/Users/gherman/Sites/whitireia/node_modules/uglify-js/tools/node.js:85:22)
    at /Users/gherman/Sites/whitireia/node_modules/uglify-js/tools/node.js:104:17
    at Array.forEach (native)
    at Object.UglifyJS.minify (/Users/gherman/Sites/whitireia/node_modules/uglify-js/tools/node.js:102:26)
    at File.minify (/Users/gherman/Sites/whitireia/node_modules/laravel-mix/src/File.js:221:31)
    at manifest.forEach.asset (/Users/gherman/Sites/whitireia/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:60:23)
    at Array.forEach (native)
    at CustomTasksPlugin.minifyAssets (/Users/gherman/Sites/whitireia/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:56:18)
    at Compiler.compiler.plugin.stats (/Users/gherman/Sites/whitireia/node_modules/laravel-mix/src/plugins/CustomTasksPlugin.js:16:22)
    at Compiler.applyPlugins (/Users/gherman/Sites/whitireia/node_modules/tapable/lib/Tapable.js:61:14)
    at /Users/gherman/Sites/whitireia/node_modules/webpack/lib/Compiler.js:273:13
    at Compiler.emitRecords (/Users/gherman/Sites/whitireia/node_modules/webpack/lib/Compiler.js:369:37)
    at /Users/gherman/Sites/whitireia/node_modules/webpack/lib/Compiler.js:267:12
    at /Users/gherman/Sites/whitireia/node_modules/webpack/lib/Compiler.js:362:11
    at next (/Users/gherman/Sites/whitireia/node_modules/tapable/lib/Tapable.js:154:11)
    at Compiler.compiler.plugin (/Users/gherman/Sites/whitireia/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at Compiler.applyPluginsAsyncSeries1 (/Users/gherman/Sites/whitireia/node_modules/tapable/lib/Tapable.js:158:13)
    at Compiler.afterEmit (/Users/gherman/Sites/whitireia/node_modules/webpack/lib/Compiler.js:359:8)
    at Compiler.<anonymous> (/Users/gherman/Sites/whitireia/node_modules/webpack/lib/Compiler.js:354:14)
    at /Users/gherman/Sites/whitireia/node_modules/async/dist/async.js:421:16
    at iteratorCallback (/Users/gherman/Sites/whitireia/node_modules/async/dist/async.js:998:13)
    at /Users/gherman/Sites/whitireia/node_modules/async/dist/async.js:906:16
    at /Users/gherman/Sites/whitireia/node_modules/graceful-fs/graceful-fs.js:43:10
    at FSReqWrap.oncomplete (fs.js:135:15)

The file it references is being compiled and stored at that path successfully, so my suspicion is that the minifier’s path wrangling is a little off.

Steps To Reproduce:

I have cross-env and webpack added as direct dependencies of the project, and my production build command looks like this:

node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/.bin/webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

My webpack.mix.js config:

const mix = require('laravel-mix');

mix
  .js('themes/_shared/src/js/enrolment/enrolment.js', 'themes/_shared/dist/');

mix.options({
  processCssUrls: false,
});

if (!mix.inProduction()) {
  // linting
  mix.webpackConfig({
    module: {
      rules: [
        {
          test: /\.(js|vue)$/,
          exclude: /node_modules/,
          loader: 'eslint-loader',
        },
      ],
    },
  });

  mix.sourceMaps();
}

enrolment.js pulls in a number of its own dependencies (Vue components, etc.) but I don’t believe the source code is related to this issue, as I’ve tried a completely fresh project with the same paths but an empty source file and I get the same error.

Let me know if there’s any additional info that would be useful.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

2reactions
JeffreyWaycommented, Jun 20, 2017

@bbashy - It’ll still do manual minification for combining scripts. If you’re getting an error, make sure that the files aren’t using ES2015+ syntax. If they are, you’ll need to use mix.babel() instead to compile everything first.

1reaction
Cheddamcommented, Jun 20, 2017

@JeffreyWay Fixed! Thanks for the speedy turnaround, and also just for building Mix in the first place 🥇

Read more comments on GitHub >

github_iconTop Results From Across the Web

Minification failures after 1.0.0 upgrade · Issue #899 - GitHub
After upgrading to Laravel Mix 1.0.0, I can no longer run a production build, as the minification fails citing an inability to find...
Read more >
Error on installing the app when minify = true - Stack Overflow
Here is how I solved it. First, disable obfuscation so you can see which methods are wrongly removed. Add the following to proguard-rules.pro...
Read more >
express-minify | Yarn - Package Manager
Automatically minify (and cache) your JavaScript, CSS and JSON responses without pain. It also supports LESS/SASS/Stylus/CoffeeScript compiling and ...
Read more >
Changelog: Twilio Conversations JavaScript SDK
Client initialization no longer fails with broken conversations. Class name SyncError will no longer get minified in minified bundles. Attribute parsing has ...
Read more >
Getting Started - Materialize
Learn how to quickly get started using our CSS framework. We have guides for a variety of skill levels.
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