Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Honor the public path by removing "/" from generated CSS and JS files #1717
This issue was also mentioned in Workbox repository:
Up until v1.7.2, Laravel-Mix was outputting the
When upgraded to v2.1.11, I noticed a double slash in the path:
This ends up resulting these two files to be loaded from
However, this works fine for anyone running out-of-the box installation of Laravel. But when the application starts growing and you want to integrate a service worker plugin (i.e. Workbox), then the real monster comes to play (see the Steps To Reproduce section below).
This is only because Laravel-Mix isn't honoring the public path in the first place. Regardless of v1.7.2 or v2.1.11, it shouldn't set the path to "/" after compiling the scripts and sass files. It should rather set the paths relative, such as: "js/app.js" and "css/app.css" instead of "/js/app.js" and "/css/app.css".
I noticed the fonts and images aren't using this leading "/" while outputting them in the public directory. Only the js and css files are including it.
To understand what's being generated from the Workbox plugin, take a look at my precache manifest file generated by the workbox plugin (refer to the Steps To Reproduce section below) while using Laravel Mix v1.7.2:
This worked for me until the forward slashes doubled in Laravel Mix v2.1.11 only for js and css files:
If Laravel Mix returns the JS and CSS file paths without any leading slash, that will solve this issue. I hope @JeffreyWay will look into this.
Steps To Reproduce:
I'm having the same problem in laravel mix 2.1.
This is problematic if you want to insert script tags into a html using html webpack plugin.
I tried laravel mix 2.0 and the issue is not present in that version.
Can someone help?
my webpack.mix.js code:
output in terminal: (the js file uri's should not start with a '/')
Having the same issue with laravel mix 2.1.14.
I am trying to inject my script via the html-webpack-plugin, but i end up with
I did try to manipulate the webpack config just to see whats going on and found out that the entry file (which should be
@JeffreyWay It would be nice to know if the leading slash is intentional. At the moment it just causes problems, at least for me..
Steps To Reproduce
I am using a basic mix setup with a self written plugin called 'mix-html-builder' as an additional dependency.
And as I said, the path of my css file looks fine.
As a hacky workaround, I've added the following to my webpack.mix.js
Not too proud of the solution but it works. Hopefully now that @JeffreyWay has finished his site updates, he'll have a bit of time to take a look.