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.

Image is not defined

See original GitHub issue

When I try to build my site using Poi, PostCSS and webp-in-css I get the following error:

./styles/footer.css
Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/src/index.js):
Error: Loading PostCSS Plugin failed: Image is not defined

(@/home/v1rtl/Desktop/Coding/v1rtl.site/.postcssrc)
    at Array.map (<anonymous>)

As I understand this is because my site uses node.js environment and not browser one and that’s why Image is not available. How I can fix this?

My .postcssrc:

{
  "plugins": 
  {
    "precss": {},
    "autoprefixer": {},
    "webp-in-css": {},
    "cssnano": {
      "preset": "default"
    }
  }

One of styles that uses webp:

header {
  display: flex;
  align-items: center;
  flex-direction: column;
  user-select: none;
  height: 100vh;
  background-image: url('../assets/background.webp');
}

If you need to check all the files, repo is here

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
aicommented, Aug 11, 2019

I renamed index.js to polyfill.js to avoid this mistake in the future https://github.com/ai/webp-in-css/commit/e4f6959e6e3c151d694bdb1cd51c5c96bb707f34

0reactions
aicommented, Aug 11, 2019

The fix was released in 0.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR: Image is not defined (trouble using Image() function)
But I receive this error: ERROR: 'Image' is not defined. [no-undef] about the part: var img = new Image(). I tried to replace...
Read more >
Getting the "img not defined" reference error in the console
In "fetchBreedImage", a variable named "image" is defined; but references are made to "img", which is not defined.
Read more >
Node.js new Image() is not defined · Issue #17 - GitHub
Browsers already have image manipulation built into them (because they need to do have a way to decode the images either way), node...
Read more >
"image" is not defined in this scope - GIS Stack Exchange
'image' is not defined tells you the problem. You have not defined the image variable anywhere before you try to use it. You...
Read more >
NameError: name 'image' is not defined - PsychoPy Discourse
Hello! I am trying to finish up my task. It is a quick detection task where the participant has to quickly identify if...
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