shashank_90's avatar

Possible to change publicPath for one file only without affecting others in pipelines

I was looking for a way to change the publicPath url in one of my specific files without affecting those other files which are in pipeline.

So let's say i have three files compiled like this using mix

mix .js('resources/js/imageEditor.js', 'public/js') .js('resources/js/app.js', 'public/js/laravel.app.js') .js('resources/js/pines-ui/pines-ui.js', 'public/js/pines-ui.js')

and i only need to change public path to process.env.APP_URL for imageEditor.js but the problem is that it is being updated in the other files as well. For getting process.env.APP_URL in js file i defined webpack plugin

mix.webpackConfig(webpack => { return { plugins: [ new webpack.DefinePlugin({ 'process.env.APP_URL': JSON.stringify(process.env.APP_URL), }), ], } })

and before i do anything else in imageEditor.js, i changed webpack global path there __webpack_public_path__ = process.env.APP_URL + '/';

and it worked but also changed in laravel.app.js and pines-ui.js as well.

How to control publicPath at individual file level?

0 likes
1 reply
shashank_90's avatar

Apologies for the incorrect question and all the confusion as this did not affect the other files.

i just saw answer from AI and it told that it would be changed for other files as well but no it won't (AI was wrong) and changing publicPath for one file is possible by changing __webpack_public_path__ variable for that file only when using mix pipelines as asked in question.

If anyone faced this, let me know or else i am happy to close this as solved...

Please or to participate in this conversation.