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.

CSS paths cannot be resolved in prod

See original GitHub issue

I created a theme.scss file in src with variables:

$body-background-color: white;
$body-background-image: url("/assets/images/bg-hexa-gray-flat.png");
$body-background-position: top left;
$body-background-repeat: repeat;

$sidepanel-background-color: white;
$sidepanel-background-image: url("/assets/images/bg-hexa-red-flat.png");
$sidepanel-background-position: top left;
$sidepanel-background-repeat: repeat;

It works with npm start but once I run electron in prod, I get an error file file:///assets/images/bg-hexa-gray-flat.png not found. How do you make your CSS paths work in prod?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
cyrilfrcommented, Jan 15, 2020

I found a solution by adding an alias to the webpack config file:

config.resolve = {
  alias: {
    assets: path.resolve(__dirname, "src/assets")
  }
};

and then use url like this: url("~assets/images/bg-hexa-gray-flat.png").

0reactions
stale[bot]commented, Feb 21, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debug Local vs Production with CSS path not working on ...
I have this MVC website that I'm a part of. I noticed that the arrow images were not showing up were running LOCALLY...
Read more >
css-loader | webpack - JS.ORG
If set to false , css-loader will not parse any paths specified in url or ... All filtered url() will not be resolved...
Read more >
CSS
Note: Only absolute paths may be used within CSS custom properties, not relative paths. This is because url() references in custom properties are...
Read more >
Java Files - java.nio.file.Files Class
Path represents location of the file and when we create a Path to new file, it does not create actual file until we...
Read more >
Content Configuration
Using relative paths. By default Tailwind resolves non-absolute content paths relative to the current working directory, not the tailwind.config.js 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