roetzer's avatar
Level 13

npm run prod crashes app

Laravel Mix Version: 6.0.49 Node Version (node -v): 12.22.5 NPM Version (npm -v): 6.14.14 OS: CentOS 7

Description: I have an issue, that is related to Mix or Webpack: if I run npm run dev or npm run watch everything works, but as soon as I am trying to do npm run prod, the app is rendered and the page becomes blank after the js file is loaded. The App is using Vue3 with composition API and script setup - As backend we use laravel with nWidart/laravel-modules, hence the multiple js files.

My mix file looks as following:

const path = require('path') const mix = require('laravel-mix')

require('laravel-mix-merge-manifest'); mix.mergeManifest();

mix.alias({ '@': path.join(__dirname, 'resources/js') });

mix.js('resources/js/app.js', 'public/js') .js('modules/module1/Resources/assets/js/module1.js', 'public/js') .js('modules/module2/Resources/assets/js/module2.js', 'public/js') .js('modules/module3/Resources/assets/js/module3.js', 'public/js') .js('modules/module4/Resources/assets/js/module4.js', 'public/js') .js('modules/module5/Resources/js/module5.js', 'public/js') .vue() .version() .postCss('resources/css/app.css', 'public/css', [ require('tailwindcss'), ])

if (mix.inProduction()) { mix.sourceMaps() }

Steps To Reproduce:

run npm run dev or npm run watch (mix/mix watch) -> everything works run npm run prod (mix --production) -> app crashes (log stays empty) and only a blank page is rendered

0 likes
1 reply
LaryAI's avatar
Level 58

One possible solution to this issue could be to try running npm run prod with the --verbose flag to get more detailed output on what might be causing the crash. Additionally, it may be helpful to check the browser console for any error messages that could provide more insight into the issue.

Another possible solution could be to try disabling any plugins or features in the mix file that may be causing conflicts with the production build. For example, commenting out the mix.sourceMaps() line in the mix file could potentially resolve the issue.

if (mix.inProduction()) {
  // mix.sourceMaps()
}

It may also be helpful to try updating the versions of Laravel Mix and any related dependencies to the latest stable releases to ensure compatibility with the current environment.

Please or to participate in this conversation.