First problem was when I wanted to extract
vendors in webpack, chunk files where in the public folder and CSS file is empty.
What I have :
public/css/app.css
(empty file !)public/js/app.js
(ok but sooo big)public/js/0.js
,public/js/1.js
, ... (chunk files)
To avoid that, we export the JS and CSS webpack configurations in two separate files :
We will use the webpack-chunk-rename-plugin to copy chunk files in correct folder.
Install it with npm install webpack-chunk-rename-plugin --save-dev
Then create the mergeManifest.js file and update your package.json.
The result after npm run dev
is :
public/css/app.css
(not empty file)public/js/chunks/0.js
,public/js/chunks/1.js
, ... (chunk files)public/js/app.js
public/js/manifest.js
public/js/vendor.js
public/mix-manifest.json
In your Blade file you need to add these lines :
<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('js/vendor.js') }}"></script>
<script src="{{ mix('js/app.js') }}"></script>
When I run npm run watch
on Windows 10, only the JS task is launched, not the SASS (not tested on Linux).
You can launch it separatly with npm run watch.css