Skip to content

Commit

Permalink
feat(config): allow only setupFile.browser or .server
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Oct 9, 2022
1 parent 082ad07 commit 79f2bd4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
10 changes: 10 additions & 0 deletions packages/histoire-shared/src/types/config.ts
Expand Up @@ -128,6 +128,16 @@ export interface HistoireConfig {
* Only loaded in the browser client.
*/
browser: string
} | {
/**
* Only loaded while collecting stories in the node server.
*/
server: string
} | {
/**
* Only loaded in the browser client.
*/
browser: string
/**
* Only loaded while collecting stories in the node server.
*/
Expand Down
15 changes: 8 additions & 7 deletions packages/histoire/src/node/vite.ts
Expand Up @@ -196,17 +196,18 @@ export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context)
let file: string
if (typeof setupFileConfig === 'string') {
file = setupFileConfig
} else if (isServer) {
} else if (isServer && 'server' in setupFileConfig) {
file = setupFileConfig.server
} else {
} else if ('browser' in setupFileConfig) {
file = setupFileConfig.browser
}
return this.resolve(resolve(ctx.root, file), importer, {
skipSelf: true,
})
} else {
return NOOP_ID
if (file) {
return this.resolve(resolve(ctx.root, file), importer, {
skipSelf: true,
})
}
}
return NOOP_ID
}
if (id.startsWith(CONFIG_ID)) {
return RESOLVED_CONFIG_ID
Expand Down

0 comments on commit 79f2bd4

Please sign in to comment.