A publicPath pointing outside the root folder -> incorrect paths for the js file
See original GitHub issue- Laravel Mix Version: 1.0.5
- Node Version (
node -v
): 8.1.2 - NPM Version (
npm -v
): 5.0.3 - OS: MacOS X 10.12.5
Description:
A publicPath pointing outside the root folder where npm is run does result in incorrect paths for the js file (css/copyDirectory does still work). The elixir framework phoenix does have a nested assets folder for it’s npm stuff, whereas the public path is in a different branch from the project root:
root
|-assets
| |- static
| | |- logo, …
| |- package.json
| |- webpack.mix.js
|-priv
|- static
|- js
|- css
Steps To Reproduce:
mix.setPublicPath('../priv/static')
.js('js/app.js', 'js/app.js')
.sass('css/app.scss', 'css/app.css')
.copyDirectory('./static', '../priv/static');
This results in the following output of webpack:
/Users/benni/Sites/madeit/priv/static/js/app.js 182 kB 0 [emitted] …
css/app.css 152 kB 0 [emitted] …
Meaning the js file is being put in ../priv/static/Users/benni/[…]
Temp. fix
ln -s ../priv/static output
and
mix.setPublicPath('output')
.js('js/app.js', 'js/app.js')
.sass('css/app.scss', 'css/app.css')
.copyDirectory('./static', 'output');
Using that results in:
/js/app.js 182 kB 0 [emitted] /js/app
css/app.css 152 kB 0 [emitted] /js/app
and therefore correct paths (still curious about the leading /).
Issue Analytics
- State:
- Created 6 years ago
- Comments:9
Top Results From Across the Web
A publicPath pointing outside the root folder -> incorrect paths ...
Problem is that the File instance is not resolving publicPath, only rootPath. Because of files that are in root path we should resolve...
Read more >Public Path - webpack
It allows you to specify the base path for all the assets within your application. Use Cases. There are a few use cases...
Read more >reactjs - Relative path in index.html after build - Stack Overflow
I'm using Photino.io building React JS to create UI for .NET cross-platform apps & the package.json was not using this so it couldn't...
Read more >How to solve vue.js prod build assets relative path problem
I installed the Visual Studio Code and opened the project and looked into the folders and files. I compiled the project using the...
Read more >Relative and absolute paths, in the file system and on the web ...
If you don't supply the root, it means that your path is relative. The simplest example of relative path is just a file...
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
The PR #964 fixed the issue, it should be released soon 👍
@TopFuel tried your fix and now it works fine. With that i can revert my code to the previous version and works. Thank you.