web: fix storybook build after npm update (#7855)
* web: fix storybookbuild build after npm update
This commit follows the [patch for Turnstile](https://github.com/goauthentik/authentik/pull/7854) and
performs a similar operation for the Storybook build, which failed after the latest `npm audit` and
`npm update` passes.
[This patch to Vite](https://github.com/vitejs/vite/pull/10762) fixes a problem with the Vite build
in that Vite could not resolve if a CSS import was strictly at the module level or if it was
necessary to include the imported CSS at the document level. The fix is to hack a query, `?inline`,
to the end of the import string, to indicate that it's a module-only import.
The Storybook for Web Components build recommended by the Open Webcomponent Consortium is a
Storybook-Vite implementation. The latest update fully deprecated undecorated CSS imports, and
Storybook broke, unable to reconcile the CSS imports.
This patch inlines the inlining of the CSS automatically for Storybook by using the Rollup
`modify()` plug-in which performs string substitutions on the source code before it's presented to
the compiler and bundler; it recognizes the strings that require inlining, those that match the
regex:
``` JavaScript
/^(import \w+ from .*\.css)";/
```
... and replaces them with a version ending in `.css?inline`. Because the actual recognizer inside
`modify()` recognizes strings and not regular expressions, a script to build the strings has been
added to the `scripts` folder.
Just like locales, you will have to re-run and re-build `build-storybook-import-maps` script if you
add a new CSS file to the source tree.
* web: prettier had opinions
* web: apply eslint + sonarjs check to the scripts folder.
* Google recaptcha (aka Turnstile) doesn't understand the "invisible" setting; that's purely
an HCaptcha thing.
* web: removing the typecast means I no longer need the type.
* web: prettier is still having opinions, dammit.
2023-12-18 14:57:39 +00:00
|
|
|
// THIS IS A GENERATED FILE. DO NOT EDIT BY HAND.
|
|
|
|
//
|
|
|
|
// This file is generated by the build-storybook-import-maps script in the UI's base directory.
|
|
|
|
// This is a *hack* to work around an inconsistency in the way rollup, vite, and storybook
|
|
|
|
// import CSS modules.
|
|
|
|
//
|
|
|
|
// Sometime around 2030 or so, the Javascript community may finally get its collective act together
|
|
|
|
// and we'll have one unified way of doing this. I can only hope.
|
|
|
|
|
2023-12-27 19:25:47 +00:00
|
|
|
const cssImportMapSources = [
|
|
|
|
'import AKGlobal from "@goauthentik/common/styles/authentik.css";',
|
|
|
|
'import PFAlert from "@patternfly/patternfly/components/Alert/alert.css";',
|
|
|
|
'import PFAlertGroup from "@patternfly/patternfly/components/AlertGroup/alert-group.css";',
|
|
|
|
'import PFAvatar from "@patternfly/patternfly/components/Avatar/avatar.css";',
|
|
|
|
'import PFBackdrop from "@patternfly/patternfly/components/Backdrop/backdrop.css";',
|
|
|
|
'import PFBackgroundImage from "@patternfly/patternfly/components/BackgroundImage/background-image.css";',
|
|
|
|
'import PFBanner from "@patternfly/patternfly/components/Banner/banner.css";',
|
|
|
|
'import PFBase from "@patternfly/patternfly/patternfly-base.css";',
|
|
|
|
'import PFBrand from "@patternfly/patternfly/components/Brand/brand.css";',
|
|
|
|
'import PFBullseye from "@patternfly/patternfly/layouts/Bullseye/bullseye.css";',
|
|
|
|
'import PFButton from "@patternfly/patternfly/components/Button/button.css";',
|
|
|
|
'import PFCard from "@patternfly/patternfly/components/Card/card.css";',
|
|
|
|
'import PFCheck from "@patternfly/patternfly/components/Check/check.css";',
|
|
|
|
'import PFChip from "@patternfly/patternfly/components/Chip/chip.css";',
|
|
|
|
'import PFChipGroup from "@patternfly/patternfly/components/ChipGroup/chip-group.css";',
|
|
|
|
'import PFContent from "@patternfly/patternfly/components/Content/content.css";',
|
|
|
|
'import PFDataList from "@patternfly/patternfly/components/DataList/data-list.css";',
|
|
|
|
'import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";',
|
|
|
|
'import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css";',
|
|
|
|
'import PFDrawer from "@patternfly/patternfly/components/Drawer/drawer.css";',
|
|
|
|
'import PFDropdown from "@patternfly/patternfly/components/Dropdown/dropdown.css";',
|
|
|
|
'import PFDropdown from "@patternfly/patternfly/components/Dropdown/dropdown.css";',
|
|
|
|
'import PFDualListSelector from "@patternfly/patternfly/components/DualListSelector/dual-list-selector.css";',
|
|
|
|
'import PFEmptyState from "@patternfly/patternfly/components/EmptyState/empty-state.css";',
|
|
|
|
'import PFExpandableSection from "@patternfly/patternfly/components/ExpandableSection/expandable-section.css";',
|
|
|
|
'import PFFAIcons from "@patternfly/patternfly/base/patternfly-fa-icons.css";',
|
|
|
|
'import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css";',
|
|
|
|
'import PFForm from "@patternfly/patternfly/components/Form/form.css";',
|
|
|
|
'import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";',
|
|
|
|
'import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";',
|
|
|
|
'import PFGlobal from "@patternfly/patternfly/patternfly-base.css";',
|
|
|
|
'import PFGrid from "@patternfly/patternfly/layouts/Grid/grid.css";',
|
|
|
|
'import PFHint from "@patternfly/patternfly/components/Hint/hint.css";',
|
|
|
|
'import PFInputGroup from "@patternfly/patternfly/components/InputGroup/input-group.css";',
|
|
|
|
'import PFLabel from "@patternfly/patternfly/components/Label/label.css";',
|
|
|
|
'import PFList from "@patternfly/patternfly/components/List/list.css";',
|
|
|
|
'import PFLogin from "@patternfly/patternfly/components/Login/login.css";',
|
|
|
|
'import PFModalBox from "@patternfly/patternfly/components/ModalBox/modal-box.css";',
|
|
|
|
'import PFNav from "@patternfly/patternfly/components/Nav/nav.css";',
|
|
|
|
'import PFNotificationBadge from "@patternfly/patternfly/components/NotificationBadge/notification-badge.css";',
|
|
|
|
'import PFNotificationDrawer from "@patternfly/patternfly/components/NotificationDrawer/notification-drawer.css";',
|
|
|
|
'import PFPage from "@patternfly/patternfly/components/Page/page.css";',
|
|
|
|
'import PFPagination from "@patternfly/patternfly/components/Pagination/pagination.css";',
|
|
|
|
'import PFProgressStepper from "@patternfly/patternfly/components/ProgressStepper/progress-stepper.css";',
|
|
|
|
'import PFRadio from "@patternfly/patternfly/components/Radio/radio.css";',
|
|
|
|
'import PFSelect from "@patternfly/patternfly/components/Select/select.css";',
|
|
|
|
'import PFSidebar from "@patternfly/patternfly/components/Sidebar/sidebar.css";',
|
|
|
|
'import PFSizing from "@patternfly/patternfly/utilities/Sizing/sizing.css";',
|
|
|
|
'import PFSpacing from "@patternfly/patternfly/utilities/Spacing/spacing.css";',
|
|
|
|
'import PFSpinner from "@patternfly/patternfly/components/Spinner/spinner.css";',
|
|
|
|
'import PFStack from "@patternfly/patternfly/layouts/Stack/stack.css";',
|
|
|
|
'import PFSwitch from "@patternfly/patternfly/components/Switch/switch.css";',
|
|
|
|
'import PFTable from "@patternfly/patternfly/components/Table/table.css";',
|
|
|
|
'import PFTabs from "@patternfly/patternfly/components/Tabs/tabs.css";',
|
2024-01-04 19:10:41 +00:00
|
|
|
'import PFTextInputGroup from "@patternfly/patternfly/components/TextInputGroup/text-input-group.css";',
|
2023-12-27 19:25:47 +00:00
|
|
|
'import PFTitle from "@patternfly/patternfly/components/Title/title.css";',
|
|
|
|
'import PFToggleGroup from "@patternfly/patternfly/components/ToggleGroup/toggle-group.css";',
|
|
|
|
'import PFToolbar from "@patternfly/patternfly/components/Toolbar/toolbar.css";',
|
|
|
|
'import PFTreeView from "@patternfly/patternfly/components/TreeView/tree-view.css";',
|
|
|
|
'import PFWizard from "@patternfly/patternfly/components/Wizard/wizard.css";',
|
|
|
|
'import ThemeDark from "@goauthentik/common/styles/theme-dark.css";',
|
|
|
|
'import styles from "./LibraryPageImpl.css";',
|
|
|
|
];
|
|
|
|
|
|
|
|
export const cssImportMaps = cssImportMapSources.reduce(
|
|
|
|
(acc, source) => ({ ...acc, [source]: source.replace(".css", ".css?inline") }),
|
|
|
|
{},
|
|
|
|
);
|