From 00619f90f11b5790b4f28fb18c0e1ef5ee8a9731 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 24 May 2024 10:05:43 +0200 Subject: [PATCH] Fix csf plugin for webpack and rspack --- code/lib/csf-plugin/package.json | 2 +- code/lib/csf-plugin/src/index.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/code/lib/csf-plugin/package.json b/code/lib/csf-plugin/package.json index b416dbe4f301..cb39114b2f56 100644 --- a/code/lib/csf-plugin/package.json +++ b/code/lib/csf-plugin/package.json @@ -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", diff --git a/code/lib/csf-plugin/src/index.ts b/code/lib/csf-plugin/src/index.ts index 62100f6d39d1..6ba413a88074 100644 --- a/code/lib/csf-plugin/src/index.ts +++ b/code/lib/csf-plugin/src/index.ts @@ -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; @@ -16,19 +17,21 @@ export const unplugin = createUnplugin((options) => { }, webpack(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'), }, }); }, 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'), }, }); },