setPublicPath sets wrong path when using mix.js()
See original GitHub issue- Laravel Mix Version: 1.0.7
- Node Version: 6.10.2
- NPM Version: 5.0.4
- OS: Windows 7 Ultimate x64
Description:
I’m trying to relocate my assets to an ‘assets’ subfolder inside /public. The mix-manifest.json gets created in the correct location and mix.less() outputs my CSS files and updates the reference in the manifest with the correct location as well. The mix.js() method however behaves strangely, as you can see in the screenshot.
I’m using the simplest possible setup to demonstrate this - a fresh installation of Laravel and npm install. I have tried adding and removing slashes all over the place, but to no avail.
Steps To Reproduce:
- Edit the webpack.mix.js file with the following:
mix.setPublicPath('public/assets');
mix.js('resources/assets/js/index.js', 'js');
mix.less('resources/assets/less/index.less', 'css');
npm run dev
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:13
Top Results From Across the Web
setPublicPath sets wrong path when using mix.js() · Issue #960
I'm trying to relocate my assets to an 'assets' subfolder inside /public. The mix-manifest.json gets created in the correct location and mix.
Read more >Frequently Asked Questions | Laravel Mix Documentation
Just be sure to explicitly set the path to your project's public or dist directory, like so: mix.setPublicPath('dist');. This tells Mix the basic...
Read more >Laravel mix.js() using absolute path after publicPath is set
Is this an issue with mix or am I doing something wrong? I only have a problem with mix.js() , everything else works...
Read more >How to use the laravel-mix.setPublicPath function in ... - Snyk
setPublicPath examples, based on popular ways it is used in public projects. ... const mix = require("laravel-mix") const path = require("path") const ...
Read more >Laravel Mix is compiling files to a wrong directory - Laracasts
Hey, I am using Laravel Mix for the first time in a stand-alone project and I am facing a problem I can't solve....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can confirm that using
path.normalize
onmix.setPublicPath
fixes the issue where I needed to change from:to:
for it to work correctly, or it would freeze at
95% emitting
on thenpm run development
command, and outputs this to the mix-manifest.json:But adding
path.normalize
fixes it:mix-manifest.json:
Hey! I’m having some throubles with this too. Actually I have a project from tree weeks ago with last mix version at that moment (0.*) and the public path was working fine. Today I start a new project and I realize that already comes with the Mix 1.1.1.
So, I basically copy / paste my webpack.mix and this issue appears…
My public path is somehing like ‘public/assets/www/…’ so then I have website folders for css, images, fonts, js etc…
I think I figure it out by using the path.normalize inside setPublicPath like this:
mix.setPublicPath(path.normalize('public/assets/www/'));
but I want to know if now this is the way to use the custom path.
My configuration its actually the same that @omnichronous uses…
Btw, I’m using Windows 10 x64.