Skip to content

Commit

Permalink
Fix style issues in Storybook production build
Browse files Browse the repository at this point in the history
The Storybook production build injects some CSS into the iframe
used to render the stories. This uses nesting, which while well
supported in browsers, causes issues with some build tooling which
is not expecting it.

The `vite-plugin-html` minifies the CSS in any `style` tags by default,
but this minification process does not account for nested CSS. The
net result of this is that some of the styles which are expected
to be scoped to `.sb-errordisplay` end up applying globally instead.

The most obvious manifestation of this was on the PipelineRun details
story where there was an additional gap between each Task in the TaskTree
caused by an unexpected `li+li` rule.

Disable CSS minification in the HTML plugin since we don't need this
for Storybook, and don't make use of `style` tags as part of the template
for the Dashboard application itself.
  • Loading branch information
AlanGreene authored and tekton-robot committed Oct 24, 2024
1 parent 1185b2d commit 1186737
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export default defineConfig(({ mode }) => ({
target: 'es2022'
},
plugins: [
createHtmlPlugin({}),
// disable CSS minification since we don't use it ourselves and it causes
// problems with use of CSS nesting in Storybook production build
createHtmlPlugin({ minify: { minifyCSS: false } }),
react({ devTarget: 'es2022' }),
svgr(),
yaml(),
Expand Down

0 comments on commit 1186737

Please sign in to comment.