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.

Storybook (webpack 5) breaks images inline loaders

See original GitHub issue

Describe the bug Requiring an image (png/svg) with inline loaders provides wrong output that ignores these loaders.

testImage = require('!file-loader!./images/test-image.png').default;
testIcon = require('!html-loader!image-webpack-loader!./images/test-icon.svg');

To Reproduce

https://github.com/artaommahe/-storybook-webpack5-inline-loaders

  • yarn install
  • yarn storybook
  • see wrong images urls and content in AppComponent’s template (testImage’s require here contains similar path as testIcon)
image:

icon: "static/media/src/app/images/test-icon..svg"
  • yarn start (to run angular dev server)
  • see proper images urls and content in AppComponent’s template
image: "747f39b8dc75b31017d31bca80ccaf2e.png"

icon: { "default": "<svg ...</svg>" }

Same issue with require.context (uncomment it in AppComponent’s OnInit method and comment out requires)

System

Environment Info:

  System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
  Binaries:
    Node: 12.18.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 91.0.4472.124
    Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.59)
  npmPackages:
    @storybook/addon-actions: ^6.3.2 => 6.3.2
    @storybook/addon-essentials: ^6.3.2 => 6.3.2
    @storybook/addon-links: ^6.3.2 => 6.3.2
    @storybook/angular: ^6.3.2 => 6.3.2
    @storybook/builder-webpack5: ^6.3.2 => 6.3.2
    @storybook/manager-webpack5: ^6.3.2 => 6.3.2

Additional context Worked fine with storybook 6.2.9

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:26 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
artaommahecommented, Jul 7, 2021

btw current workaround is to remove images loader in webpack config customisation

config.module.rules = config.module.rules.filter(rule => !rule.test || !rule.test.source.includes('png'));
1reaction
shilmancommented, Jul 2, 2021

@artaommahe just venting a bit, thanks for being patient with us on this! 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Images, fonts, and assets - Storybook - JS.ORG
Components often rely on images, videos, fonts, and other assets to render as the user expects. There are many ways to use these...
Read more >
Upgrade To Webpack 5 Breaking Storybook 5 - ADocLib
Storybook webpack 5 breaks images inline loaders #15438.artaommahe posted onGitHub.Describe the bug Requiring an image png/svg with inline loaders.
Read more >
storybook/addon-docs - npm
Start using @storybook/addon-docs in your project by running `npm i ... such as props tables and inline story rendering.
Read more >
Migrating to Webpack 5 at smallcase - Medium
We use Post CSS and CSS Modules in our codebase, and have loaders in place to run this setup. We have environment specific...
Read more >
After updating my Storybook from 5.3 to Storybook 6.2, I'm ...
Problem with Webpack or Storybook? ... \Desktop\Workspace\project\asset\node_modules\enhanced-resolve\lib\Resolver.js:285:5 at eval (eval at ...
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