question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
TopFuelcommented, Jul 5, 2017

The PR #964 fixed the issue, it should be released soon 👍

1reaction
wanted80-zzcommented, Jun 30, 2017

@TopFuel tried your fix and now it works fine. With that i can revert my code to the previous version and works. Thank you.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found