LaraBABA's avatar

Laravel mix issue paths on development and production

Hello,

I am create my apps locally and upload them to my production server. When running:

npm run dev

I need my mix local paths

When running

npm run production

I need my mix_url path to be added.

At the moment, whatever I run always add the mix_url path to the output files.

As the doc says, I have added this on my local version:

    'mix_url' => env('MIX_ASSET_URL', null),

I added my production server path to the ENV file.

My issue now is that in the webpack.mix.js I have this:

    if(process.env.APP_ENV == "production"){
    mix.version();
    }

I was hoping that by running: npm run dev

The local path would stay "as is", but instead I am getting the URL set in the 'mix_url'.

Any idea why please?

Is there a way to stop this from happening when running "npm run dev" or "npm run watch" ?

0 likes
2 replies
gitwithravish's avatar

How about

if(process.env.APP_ENV == "production"){
	mix.setPublicPath('path1');
}else{
	mix.setPublicPath('path2');
}

//rest of the code
LaraBABA's avatar

Thanks,

I am not sure I understand the solution. You want me to generate the output in different folders?

Please or to participate in this conversation.