diff --git a/packages/histoire/src/node/plugin.ts b/packages/histoire/src/node/plugin.ts index dc1c5951..b43b53df 100644 --- a/packages/histoire/src/node/plugin.ts +++ b/packages/histoire/src/node/plugin.ts @@ -40,8 +40,8 @@ export async function createVitePlugins (ctx: Context): Promise { load (id) { if (id === RESOLVED_STORIES_ID) { - return `${stories.map((story, index) => `import Comp${index} from '/${story.file}'`).join('\n')} -export let files = [${stories.map((story, index) => `{ id: '${story.id}', file: '/${story.file}', component: Comp${index} }`).join(',\n')}] + return `${stories.map((story, index) => `import Comp${index} from '${story.file}'`).join('\n')} +export let files = [${stories.map((story, index) => `{ id: '${story.id}', file: '${story.file}', component: Comp${index} }`).join(',\n')}] const handlers = [] export function onUpdate (cb) { handlers.push(cb) diff --git a/packages/histoire/src/node/stories.ts b/packages/histoire/src/node/stories.ts index bcada99e..5b459dd6 100644 --- a/packages/histoire/src/node/stories.ts +++ b/packages/histoire/src/node/stories.ts @@ -2,6 +2,7 @@ import { Context } from './context.js' import chokidar from 'chokidar' import { globby } from 'globby' import Case from 'case' +import { join } from 'pathe' export interface Story { id: string @@ -21,7 +22,8 @@ export async function watchStories (ctx: Context) { cwd: ctx.config.sourceDir, }) watcher.on('add', (file) => { - addStory(file) + const absoluteFilePath = join(ctx.config.sourceDir, file) + addStory(absoluteFilePath) notifyChange() }) watcher.on('unlink', (file) => {