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

web: simplify ?inline handler for Storybook #12246

Merged
merged 17 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 0 additions & 84 deletions web/.storybook/css-import-maps.ts

This file was deleted.

19 changes: 16 additions & 3 deletions web/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import modify from "rollup-plugin-modify";
import postcssLit from "rollup-plugin-postcss-lit";
import tsconfigPaths from "vite-tsconfig-paths";

import { cssImportMaps } from "./css-import-maps";

export const isProdBuild = process.env.NODE_ENV === "production";
export const apiBasePath = process.env.AK_API_BASE_PATH || "";

const importInlinePatterns = [
'import AKGlobal from "(\\.\\./)*common/styles/authentik\\.css',
'import AKGlobal from "@goauthentik/common/styles/authentik\\.css',
'import PF.+ from "@patternfly/patternfly/\\S+\\.css',
'import ThemeDark from "@goauthentik/common/styles/theme-dark\\.css',
'import styles from "\\./LibraryPageImpl\\.css',
];

const importInlineRegexp = new RegExp(importInlinePatterns.map((a) => `(${a})`).join("|"));

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
Expand Down Expand Up @@ -43,7 +51,12 @@ const config: StorybookConfig = {
return {
...config,
plugins: [
modify(cssImportMaps),
modify({
find: importInlineRegexp,
replace: (match: RegExpMatchArray) => {
return `${match}?inline`;
},
}),
replace({
"process.env.NODE_ENV": JSON.stringify(
isProdBuild ? "production" : "development",
Expand Down
15 changes: 11 additions & 4 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@
"pseudolocalize": "wireit",
"storybook": "storybook dev -p 6006",
"storybook:build": "wireit",
"storybook:build-import-map": "wireit",
"test": "wireit",
"test:e2e": "wireit",
"test:e2e:watch": "wireit",
"test:watch": "wireit",
"tsc": "wireit",
Expand Down Expand Up @@ -316,16 +316,23 @@
"NODE_OPTIONS": "--max_old_space_size=8192"
}
},
"storybook:build-import-map": {
"command": "node scripts/build-storybook-import-maps.mjs"
},
"test": {
"command": "wdio ./wdio.conf.ts --logLevel=warn",
"env": {
"CI": "true",
"TS_NODE_PROJECT": "tsconfig.test.json"
}
},
"test:e2e": {
"command": "wdio run ./tests/wdio.conf.ts",
"dependencies": [
"build"
],
"env": {
"CI": "true",
"TS_NODE_PROJECT": "./tests/tsconfig.test.json"
}
},
"test:e2e:watch": {
"command": "wdio run ./tests/wdio.conf.ts",
"dependencies": [
Expand Down
91 changes: 0 additions & 91 deletions web/scripts/build-storybook-import-maps.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion web/wdio.conf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const maxInstances =
process.env.MAX_INSTANCES !== undefined
? parseInt(process.env.MAX_INSTANCES, DEFAULT_MAX_INSTANCES)
: runHeadless
? 10
? 1
: 1;

export const config: WebdriverIO.Config = {
Expand Down
Loading