Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 6.2.3 broke our ability to put SVG icons on Storybook #15825

Closed
christopher-francisco opened this issue Aug 11, 2021 · 3 comments
Closed

Comments

@christopher-francisco
Copy link

christopher-francisco commented Aug 11, 2021

Describe the bug
I upgraded from 6.2.0-beta.9 to latest ^6.3 and suddenly my SVGs were not showing anymore. I went 1 by 1 each version to find which one breaks it and found out it's 6.2.3 I suspect the culprit could be this #14480

We're seeing this on the console

main.js:1 GET http://localhost:9002/images/icon-sprite.svg 404 (Not Found)

To Reproduce
We have a very weird way of loading up the sprite-sheet, so I don't know how could I reproduce it. I'll try to figure something out.

First thing first, the SVG is on a library that gets pulled as a dependency of the project with Storybook. The library is built with Webpack before being published to npm. This is what our Webpack does:

  1. outputs target commonjs2
mode: 'production',
output: {
  filename: 'main.js',
  path: path.resolve(__dirname, 'dist'),
  path: __dirname,
  library: 'MySVGs',
  libraryTarget: 'commonjs2'
}
  1. svg files go through file-loader
{
  test: /\.(png|jpg|gif|svg)$/,
  use: [{
    loader: 'file-loader',
    options: {
      name: '[path][name].[ext]'
    }
  }]
},
  1. package.json's main attribute goes to ./dist/main.js which is the transpiled webpack output

Additional context

I'm not sure where to start looking for a potential fix. Any guidance is appreciated!

@christopher-francisco
Copy link
Author

christopher-francisco commented Aug 11, 2021

I have confirmed #14480 is what's causing the issue: I did the following and it's showing the SVGs again on 6.2.3 and also on 6.3.4

// main.js

const svgRule = config.module.rules
  .find(rule => rule.test.toString().includes('svg')) 

config.module.rules = config.module.rules
  .filter(rule => !rule.test.toString().includes('svg')) 

svgRule.options.esModule = true;

config.module.rules.push(
  svgRule,
 // ... other rules

What's the next step? I don't really know what this property do, so I don't understand why is it breaking our SVGs

@pahan35
Copy link

pahan35 commented Oct 25, 2021

Is this issue a duplicate of #15438?

@shilman
Copy link
Member

shilman commented Jun 7, 2023

We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:

@shilman shilman closed this as not planned Won't fix, can't repro, duplicate, stale Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants