Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: import error on Windows (fix #1) #3

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/histoire/src/node/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export async function createVitePlugins (ctx: Context): Promise<Plugin[]> {

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)
Expand Down
4 changes: 3 additions & 1 deletion packages/histoire/src/node/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) => {
Expand Down