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'), }, }); },