Skip to content

fix: Allow stylesheets to be bundled in storybook production build#473

Merged
frankieyan merged 2 commits intodevfrom
frankie/fix-storybook-dist
Mar 18, 2021
Merged

fix: Allow stylesheets to be bundled in storybook production build#473
frankieyan merged 2 commits intodevfrom
frankie/fix-storybook-dist

Conversation

@frankieyan
Copy link
Member

@frankieyan frankieyan commented Mar 17, 2021

Short description

Fixes Storybook's production build so that stylesheets are included again.

This one has actually been lingering around since v6.0.0 - because we declared our package as side-effect-free (and later having declared CSS files being the only side-effects), Webpack drops our *.less imports from the production build as we simply import them, rather than passing their reference around as we do with CSS modules.

See https://webpack.js.org/configuration/module/#rulesideeffects and https://webpack.js.org/guides/tree-shaking for more details.

Since we don't expose any *.less files in the tsdx bundles, we should leave package.json as is and only declare this with Storybook's Webpack config.

Test plan

  • Open up the /docs folder in a browser (or use something like VSCode's Live Server. Verify that styles are being loaded.

PR Checklist

  • Added tests for bugs / new features
  • Updated docs (storybooks, readme)
  • Executed npm run validate and made sure no errors / warnings were shown
  • Described changes in CHANGELOG.md
  • Bumped version in package.json and package-lock.json (npm --no-git-tag-version version <major|minor|patch>) ref
  • Updated all static build artifacts (npm run build-all)

Versioning

No need for a release here

@frankieyan frankieyan requested review from a team and henningmu and removed request for a team March 17, 2021 15:02
@frankieyan frankieyan self-assigned this Mar 17, 2021
Copy link
Contributor

@henningmu henningmu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great going for the root cause – works like a charm 👏

@frankieyan frankieyan merged commit 4166c5a into dev Mar 18, 2021
@frankieyan frankieyan deleted the frankie/fix-storybook-dist branch March 18, 2021 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants