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
When attempting to compile any more than 9 .less files, the number of resulting .css files are always one short #1420
Comments
Additional note: I've just noticed that when I compile <= 9 .less files (i.e. passing cases), |
Digging into the source, I learned that the From
Knowing this, as an experiment I added a single let mix = require('laravel-mix');
mix.less('resources/less/a.less', 'css/')
.less('resources/less/b.less', 'css/')
.less('resources/less/c.less', 'css/')
.less('resources/less/d.less', 'css/')
.less('resources/less/e.less', 'css/')
.less('resources/less/f.less', 'css/')
.less('resources/less/g.less', 'css/')
.less('resources/less/h.less', 'css/')
.less('resources/less/i.less', 'css/')
.less('resources/less/j.less', 'css/')
.less('resources/less/k.less', 'css/')
.less('resources/less/l.less', 'css/');
// As long as there's just one mix.js call, all 12 .less files are compiled
mix.js('resources/assets/js/bootstrap.js', 'js/'); So, I've got a work-around for my app, but seems like there's still some underlying problem. |
Found the source of the problem in class MockEntryPlugin {
/**
* Handle the deletion of the temporary mix.js
* output file that was generated by webpack.
*
* This file is created when the user hasn't
* requested any JavaScript compilation, but
* webpack still requires an entry.
*
* @param {Object} compiler
*/
apply(compiler) {
compiler.plugin('done', stats => {
let temporaryOutputFile = stats.toJson()
.assets
.find(asset => asset.chunkNames.includes('mix'));
if (temporaryOutputFile) {
delete stats.compilation.assets[temporaryOutputFile.name];
File.find(
path.resolve(Config.publicPath, temporaryOutputFile.name)
).delete();
}
});
}
} It locates the temporary mix file with this line: let temporaryOutputFile = stats.toJson()
.assets
.find(asset => asset.chunkNames.includes('mix')); When I console.log
If I amend the definition of Before: let temporaryOutputFile = stats.toJson()
.assets
.find(asset => asset.chunkNames.includes('mix')); After: let temporaryOutputFile = stats.toJson()
.assets
.find(asset => asset.chunk.includes('mix.js')); |
Discovered a weird bug where compiling > 9 .less files was always produced .css file short. Traced it down to this function where it was deleting a compiled .css file instead of the intended `mix.js`. Full details here: laravel-mix#1420
Thanks! That's fixed now, and will be part of the next release. |
Description:
When attempting to compile any more than 9 less files (via
mix.less
), the number of resulting .css files are always one short.I ran the following tests:
Steps To Reproduce:
I replicated my problem in a fresh Laravel install which is available here:
https://github.com/susanBuck/foobar.
webpack.mix.js
is as follows:And below are the details of 5 different tests that vary the amount of
mix.less
calls by commenting them out.Between each test, I run this command...
...in order to:
public/css
(destination folder) clean for a blank slatenpm run dev
to invoke Mixpublic/css
Test 1:
Leave all 12 .less statements as is.
Invoke above-mentioned command.
.css file count:
FAIL
Test 2
Comment any ONE of the .less statements so only 11 are run.
Invoke above-mentioned command.
.css file count:
FAIL
Test 3
Comment any TWO of the .less statements so only 10 are run.
Invoke above-mentioned command.
.css file count:
FAIL
Test 4
Comment out any THREE of the .less statements so only 9 are run.
Invoke above-mentioned command.
.css file count:
PASS
Test 5
Comment out any FOUR of the .less statements so only 8 are run.
Invoke above-mentioned command.
PASS
Misc details
Here's the console output when attempting to compile 12 less files (as demonstrated in Test 1). It mirrors my file count from the test (11... one short).
The text was updated successfully, but these errors were encountered: