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.
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.
@Cheddam Thanks for the useful description. I think I've found the issue. Can you upgrade to Mix 1.0.2 and let me know if you're still hitting this snag?
I'll also try this later. Was having the same issue with combined scripts.
@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.
@JeffreyWay Oh OK, makes sense. The scripts are just plain JS though (I believe). Will check.
Edit: All fine, had some backticks that I added recently so changed it to .babel()
@JeffreyWay Fixed! Thanks for the speedy turnaround, and also just for building Mix in the first place 馃
Most helpful comment
@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.