Looks like code splitting. Show us your mix file.
Lots of Javascript created on running Mix
Running mix creates quite alot of random javascript files with names like... 0.js 1.js 2.js, etc in public folder.
Is there a way to not have those file?
We can help in a more efficient way if you post your mix file. But, check your use of extract() or comment it out to see if that is the issue. That method will produce as many files as necessary to adequately separate code.
Sorry for the late reply but here it is...
let mix = require('laravel-mix');
let ImageminPlugin = require('imagemin-webpack-plugin').default;
let CopyWebpackPlugin = require('copy-webpack-plugin');
let imageminMozjpeg = require('imagemin-mozjpeg');
/*
|--------------------------------------------------------------------------
| Mix Asset Management
|--------------------------------------------------------------------------
|
| Mix provides a clean, fluent API for defining some Webpack build steps
| for your Laravel application. By default, we are compiling the Sass
| file for the application as well as bundling up all the JS files.
|
*/
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/css/style.scss', 'public/css')
.webpackConfig({
plugins: [
new CopyWebpackPlugin([{
from: 'resources/assets/img',
to: 'img', // Laravel mix will place this in 'public/img'
}]),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
plugins: [
imageminMozjpeg({
quality: 80,
})
]
})
]
});
if (mix.config.production) {
mix.version();
}
I had to change mix.config.isProduction to mix.config.production
One suggestion, I would extract your webpackConfig() changes to the very thing...so before any tasks are run to avoid tough to track down issues. Once the config is merged, then run the tasks. In your case:
mix..webpackConfig({
plugins: [
new CopyWebpackPlugin([{
from: 'resources/assets/img',
to: 'img', // Laravel mix will place this in 'public/img'
}]),
new ImageminPlugin({
test: /\.(jpe?g|png|gif|svg)$/i,
plugins: [
imageminMozjpeg({
quality: 80,
})
]
})
]
});
mix.js('resources/assets/js/app.js', 'public/js')
.sass('resources/assets/css/style.scss', 'public/css');
Also mix is optional. Some small apps I use very little javascript and just load whats needed, or use regular javascript.
Please or to participate in this conversation.