Asset lookup while watching

While webpack watching a sage9 theme, the dist/ folder is
cleaned up (the changes are injected by webpack instead).

This can cause problems with loading from PHP (which is not involved in webpack building and run on backend) as with log1x/blade-svg-sage:

Is there a more high level asset path lookup function in sage9 that
returns the right path when watching or not watching (dev / production build)?

No. PHP isn’t aware of whether you’re running a webpack task or not, so it can’t toggle how to serve that file. In theory, you might be able to write your own code that would conditionally import files from different locations if some kind of header was present, but there’s nothing like that currently.

If I’m inlining files I treat them as code, not assets: They don’t go in the assets folder or run through the build process. IMO that’s the simplest solution to this problem.

1 Like