Skip to content

Commit

Permalink
Fix csf plugin for webpack and rspack
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed May 24, 2024
1 parent c5f9332 commit daf32a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion code/lib/csf-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"./webpack-loader": {
"./dist/webpack-loader": {
"types": "./dist/webpack-loader.d.ts",
"node": "./dist/webpack-loader.js",
"require": "./dist/webpack-loader.js",
Expand Down
9 changes: 6 additions & 3 deletions code/lib/csf-plugin/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { createUnplugin } from 'unplugin';
import type { EnrichCsfOptions } from '@storybook/csf-tools';
import { rollupBasedPlugin } from './rollup-based-plugin';
import { STORIES_REGEX } from './constants';

export type CsfPluginOptions = EnrichCsfOptions;

Expand All @@ -15,20 +16,22 @@ export const unplugin = createUnplugin<CsfPluginOptions>((options) => {
...rollupBasedPlugin(options),
},
webpack(compiler) {
compiler.options.module.rules.unshift({
compiler.options.module.rules.push({
test: STORIES_REGEX,
enforce: 'pre',
use: {
options,
loader: require.resolve('./webpack-loader'),
loader: require.resolve('@storybook/csf-plugin/dist/webpack-loader'),
},
});
},
rspack(compiler) {
compiler.options.module.rules.unshift({
test: STORIES_REGEX,
enforce: 'pre',
use: {
options,
loader: require.resolve('./webpack-loader'),
loader: require.resolve('@storybook/csf-plugin/dist/webpack-loader'),
},
});
},
Expand Down

0 comments on commit daf32a6

Please sign in to comment.