Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Add warning that config options don't affect vite
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaun Lloyd committed Apr 24, 2023
1 parent 4c042fb commit 5067355
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ const config: StorybookConfig = {
"@storybook/addon-essentials",
{
name: "./local-preset.js",
options: {},
options: {
less: {},
},
},
],
framework: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@storybook/components": "^7.0.2",
"@storybook/core-events": "^7.0.2",
"@storybook/manager-api": "^7.0.2",
"@storybook/node-logger": "^7.0.7",
"@storybook/preview-api": "^7.0.2",
"@storybook/theming": "^7.0.2",
"@storybook/types": "^7.0.2",
Expand Down
3 changes: 3 additions & 0 deletions src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { webpackFinal as webpack } from "./webpack/webpackFinal";
import { viteFinal as vite } from "./vite/viteFinal";

export const webpackFinal = webpack as any;

export const viteFinal = vite as any;
File renamed without changes.
59 changes: 59 additions & 0 deletions src/vite/viteFinal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { logger, colors } from "@storybook/node-logger";
import type { AddonStylingOptions } from "../types";

export function viteFinal(config: any, options: AddonStylingOptions = {}) {
if (options.cssModules) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.cssModules"
)}" is for webpack only. Vite comes preconfigured with css-module support.`
);
}
if (options.cssBuildRule) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.cssBuildRule"
)}" is for webpack only. To customize your CSS build, update your Vite config.`
);
}

if (options.postCss) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.postCss"
)}" is for webpack only. Vite comes preconfigured with PostCSS support.`
);
}

if (options.sass) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.sass"
)}" is for webpack only. Vite comes preconfigured with Sass/Scss support.`
);
}
if (options.scssBuildRule) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.scssBuildRule"
)}" is for webpack only. Vite comes preconfigured with Sass/Scss support.`
);
}

if (options.less) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.less"
)}" is for webpack only. Vite comes preconfigured with Less support.`
);
}
if (options.lessBuildRule) {
logger.warn(
`[@storybook/addon-styling] "${colors.blue(
"options.lessBuildRule"
)}" is for webpack only. Vite comes preconfigured with Less support.`
);
}

return config;
}
2 changes: 1 addition & 1 deletion src/webpack/css/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RuleSetRule, Configuration as WebpackConfig } from "webpack";
import type { AddonStylingOptions } from "../types";
import type { AddonStylingOptions } from "../../types";

const isRuleForCSS = (rule: RuleSetRule) =>
typeof rule !== "string" &&
Expand Down
2 changes: 1 addition & 1 deletion src/webpack/less/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RuleSetRule, Configuration as WebpackConfig } from "webpack";
import type { AddonStylingOptions } from "../types";
import type { AddonStylingOptions } from "../../types";

const isRuleForLESS = (rule: RuleSetRule) =>
typeof rule !== "string" &&
Expand Down
2 changes: 1 addition & 1 deletion src/webpack/scss/webpack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { RuleSetRule, Configuration as WebpackConfig } from "webpack";
import type { AddonStylingOptions } from "../types";
import type { AddonStylingOptions } from "../../types";

const isRuleForSCSS = (rule: RuleSetRule) =>
typeof rule !== "string" &&
Expand Down
2 changes: 1 addition & 1 deletion src/webpack/webpackFinal.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Configuration as WebpackConfig } from "webpack";
import type { AddonStylingOptions } from "./types";
import type { AddonStylingOptions } from "../types";

import { patchOrAddCssRule } from "./css/webpack";
import { patchOrAddScssRule } from "./scss/webpack";
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3163,6 +3163,16 @@
npmlog "^5.0.1"
pretty-hrtime "^1.0.3"

"@storybook/node-logger@^7.0.7":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@storybook/node-logger/-/node-logger-7.0.7.tgz#114e6d1994e0445dd9e579768bdb89adbf1055cd"
integrity sha512-5Y4LLgKeCStq1ktCKZ5eNPzQQSQ+CYZAlkEdzQ3Pp//0KXaZvVxEvGtaYhAymP2HatLpI8Oneo4lHrJioRfgww==
dependencies:
"@types/npmlog" "^4.1.2"
chalk "^4.1.0"
npmlog "^5.0.1"
pretty-hrtime "^1.0.3"

"@storybook/[email protected]":
version "7.0.2"
resolved "https://registry.yarnpkg.com/@storybook/postinstall/-/postinstall-7.0.2.tgz#cccbecb5a52ef0797d72fd919f024d785b1fb8d6"
Expand Down

0 comments on commit 5067355

Please sign in to comment.