Skip to content

Commit

Permalink
Merge pull request #16328 from storybookjs/fix-stories-entry-path
Browse files Browse the repository at this point in the history
Core: Fix paths to be relative to working dir in v7 mode
  • Loading branch information
shilman authored Oct 13, 2021
2 parents 5234731 + 6febea3 commit 9a506dd
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { StorybookConfig } from '@storybook/react/types';

const config: StorybookConfig = {
stories: [{ directory: './src', titlePrefix: 'Demo' }],
stories: [{ directory: '../src', titlePrefix: 'Demo' }],
logLevel: 'debug',
addons: [
'@storybook/react',
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions examples/react-ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "6.4.0-beta.9",
"private": true,
"scripts": {
"build-storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true build-storybook -c ./",
"debug": "cross-env NODE_OPTIONS=--inspect-brk STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011 -c ./",
"storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011 -c ./ --no-manager-cache"
"build-storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true build-storybook",
"debug": "cross-env NODE_OPTIONS=--inspect-brk STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011",
"storybook": "cross-env STORYBOOK_DISPLAY_WARNING=true DISPLAY_WARNING=true start-storybook -p 9011 --no-manager-cache"
},
"dependencies": {
"formik": "^2.2.9",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-ts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"skipLibCheck": true,
"strict": true
},
"include": ["src/*", "main.ts"]
"include": ["src/*", ".storybook/main.ts"]
}
5 changes: 2 additions & 3 deletions lib/builder-webpack4/src/preview/iframe-webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ const storybookPaths: Record<string, string> = [
);
export default async (options: Options & Record<string, any>): Promise<Configuration> => {
const {
configDir,
babelOptions,
outputDir = path.join('.', 'public'),
quiet,
Expand Down Expand Up @@ -94,10 +93,10 @@ export default async (options: Options & Record<string, any>): Promise<Configura
const virtualModuleMapping: Record<string, string> = {};
if (features?.storyStoreV7) {
const storiesFilename = 'storybook-stories.js';
const storiesPath = path.resolve(path.join(configDir, storiesFilename));
const storiesPath = path.resolve(path.join(workingDir, storiesFilename));

virtualModuleMapping[storiesPath] = toImportFn(stories);
const configEntryPath = path.resolve(path.join(configDir, 'storybook-config-entry.js'));
const configEntryPath = path.resolve(path.join(workingDir, 'storybook-config-entry.js'));
virtualModuleMapping[configEntryPath] = handlebars(
await readTemplate(path.join(__dirname, 'virtualModuleModernEntry.js.handlebars')),
{
Expand Down
5 changes: 2 additions & 3 deletions lib/builder-webpack5/src/preview/iframe-webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const storybookPaths: Record<string, string> = [

export default async (options: Options & Record<string, any>): Promise<Configuration> => {
const {
configDir,
babelOptions,
outputDir = path.join('.', 'public'),
quiet,
Expand Down Expand Up @@ -88,10 +87,10 @@ export default async (options: Options & Record<string, any>): Promise<Configura
const virtualModuleMapping: Record<string, string> = {};
if (features?.storyStoreV7) {
const storiesFilename = 'storybook-stories.js';
const storiesPath = path.resolve(path.join(configDir, storiesFilename));
const storiesPath = path.resolve(path.join(workingDir, storiesFilename));

virtualModuleMapping[storiesPath] = toImportFn(stories);
const configEntryPath = path.resolve(path.join(configDir, 'storybook-config-entry.js'));
const configEntryPath = path.resolve(path.join(workingDir, 'storybook-config-entry.js'));
virtualModuleMapping[configEntryPath] = handlebars(
await readTemplate(path.join(__dirname, 'virtualModuleModernEntry.js.handlebars')),
{
Expand Down
2 changes: 1 addition & 1 deletion lib/core-server/src/core-presets.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const baseOptions = {
managerOnly, // production
docsMode: false,
cache,
configDir: path.resolve(`${__dirname}/../../../examples/react-ts`),
configDir: path.resolve(`${__dirname}/../../../examples/react-ts/.storybook`),
outputDir: `${__dirname}/storybook-static`, // production
ci: true,
managerCache: false,
Expand Down

0 comments on commit 9a506dd

Please sign in to comment.