node -v): 8.7.0npm -v): 5.6.0Seems like this feature was dropped in the rewrite, what this does is basically allows to specify multiple mix files to process and the mix-manifest.json file will update rather than re-created from scratch every time.
This allows to have separate applications on the same installation.
This repository will demonstrate the issue and the fix applied:
https://github.com/VinceG/laravel-mix-issue-new
The following pull request was approved and merged but somehow the feature got removed during the rewrite since the 0.12 release.
https://github.com/JeffreyWay/laravel-mix/pull/609
I've added this issue as a reference a pull request will follow to the 2.0.0 branch to bring this feature back.
I found solution for this. It's look like this:
I have 2 files:
webpack.frontend.mix.js
const { mix } = require('laravel-mix');
mix.setPublicPath('public/frontend');
...
webpack.backend.mix.js
const { mix } = require('laravel-mix');
mix.setPublicPath('public/backend');
...
Separate run webpack for building: backend and frontend:
package.json
{
...
"scripts": {
"frontend-dev": "npm run frontend-development",
"frontend-development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.frontend.mix.js",
"frontend-watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.frontend.mix.js",
"frontend-watch-poll": "npm run watch -- --watch-poll",
"frontend-hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.frontend.mix.js",
"frontend-prod": "npm run frontend-production",
"frontend-production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.frontend.mix.js",
"backend-dev": "npm run backend-development",
"backend-development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.backend.mix.js",
"backend-watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.backend.mix.js",
"backend-watch-poll": "npm run watch -- --watch-poll",
"backend-hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.backend.mix.js",
"backend-prod": "npm run backend-production",
"backend-production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js --env.mixfile=webpack.backend.mix.js"
},
...
}
As a result, I'll receive 2 mix-manifest.json:
public/frontend/mix-manifest.json
public/backend/mix-manifest.json
In layout I can connect them like this:
<script src="{!! asset(mix('/frontend/js/vendor.js', 'frontend')) !!}"></script>
<script src="{!! asset(mix('/frontend/js/app.js', 'frontend')) !!}"></script>
But there is only one problem that I every time have to change a path manually:
From this
{
"/js/app.js": "/js/app.js?id=c99001026dbac41157cd",
"/js/vendor.js": "/js/vendor.js?id=b5080cf4d1f4992083c2",
}
To this
{
"/frontend/js/app.js": "/js/app.js?id=c99001026dbac41157cd",
"/frontend/js/vendor.js": "/js/vendor.js?id=b5080cf4d1f4992083c2",
}
If someone can fix it I'll be very appreciative :)
@onnsoft this PR should fix this so you won't have to do anything at all. It'll just work with multiple mix files.
@onnsoft @VinceG have you seen this approach to rewrite the manifest? Maybe this helps.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
I found solution for this. It's look like this:
I have 2 files:
webpack.frontend.mix.js
webpack.backend.mix.js
Separate run webpack for building: backend and frontend:
package.json
As a result, I'll receive 2 mix-manifest.json:
public/frontend/mix-manifest.json
public/backend/mix-manifest.json
In layout I can connect them like this:
But there is only one problem that I every time have to change a path manually:
From this
To this
If someone can fix it I'll be very appreciative :)