Laravel-mix: The manifest file gets overwritten (and invalidated) by running the tests

Created on 3 Apr 2018  路  3Comments  路  Source: JeffreyWay/laravel-mix

FYI I have done the pre-checks, none of which has solved this problem.

  • Laravel Mix Version: both 1.7.2 & 2.1.11 (npm list --depth=0)
  • Node Version (node -v): 8.7.0
  • NPM Version (npm -v): 5.8.0
  • OS: macOS High Sierra 10.13.3 (17D102)

Description:

When using {{ mix('/css/app.css') }} for example in a Blade template, Laravel relies on the mix-manifest.json file to load the appropriate - potentially versioned - asset. Running the tests the manifest file gets overwritten and the application no longer works in the browser.

Note: I'm not even sure whether it's a Laravel Mix issue, so please point me to the right place if it is not.

Steps To Reproduce:

  • clone the demo project: [email protected]:barnabaskecskes/laravel-mix-manifest.git
  • install dependencies, as usual, and generate your app key
  • run npm run dev and open your project in the browser and confirm you see the welcome page
  • run npm run tests and reload the browser - you will see an error and that the page is broken
stale

Most helpful comment

I was having the same problem running tests. This is my solution:

package.json

...
"test": "cross-env NODE_ENV=testing mocha-webpack --webpack-config webpack.config.js --require tests/JavaScript/setup.js tests/JavaScript/**/*.spec.js"
...

Notice that I have overwritten the laravel-mix/setup/webpack.config.js file with my own. It's basically a copy of the original file but with an added section:

webpack.config.js

...
if (process.env.NODE_ENV === 'testing') {
    Mix.manifest.refresh = () => {};
}
...

That fixed it for me 馃憣

All 3 comments

I was having the same problem running tests. This is my solution:

package.json

...
"test": "cross-env NODE_ENV=testing mocha-webpack --webpack-config webpack.config.js --require tests/JavaScript/setup.js tests/JavaScript/**/*.spec.js"
...

Notice that I have overwritten the laravel-mix/setup/webpack.config.js file with my own. It's basically a copy of the original file but with an added section:

webpack.config.js

...
if (process.env.NODE_ENV === 'testing') {
    Mix.manifest.refresh = () => {};
}
...

That fixed it for me 馃憣

I do confirm the issue using [email protected]

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Bomavi picture Bomavi  路  3Comments

sdebacker picture sdebacker  路  3Comments

jpmurray picture jpmurray  路  3Comments

wendt88 picture wendt88  路  3Comments

rderimay picture rderimay  路  3Comments