Skip to content

Commit

Permalink
don't make webpack users specify preprocess option
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jul 18, 2022
1 parent 5ecf339 commit 50991a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/svelte/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@storybook/docs-tools": "6.5.0-rc.1",
"@storybook/node-logger": "6.5.0-rc.1",
"@storybook/store": "6.5.0-rc.1",
"@types/node": "^14.14.20 || ^16.0.0",
"core-js": "^3.8.2",
"global": "^4.4.0",
"loader-utils": "^2.0.0",
Expand Down
8 changes: 7 additions & 1 deletion app/svelte/src/server/svelte-docgen-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ export default async function svelteDocgen(source: string) {
const { resource } = this._module;
const svelteOptions: any = { ...getOptions(this) };

const { preprocess: preprocessOptions, logDocgen = false } = svelteOptions;
let configPath = path.join(process.cwd(), './svelte.config.js');
if (!fs.existsSync(configPath)) configPath = path.join(process.cwd(), './svelte.config.mjs');
if (!fs.existsSync(configPath)) configPath = path.join(process.cwd(), './svelte.config.cjs');
if (!fs.existsSync(configPath)) throw new Error('Could not locate Svelte config file');
const config = (await import(configPath)).default;

const { preprocess: preprocessOptions = config.preprocess, logDocgen = false } = svelteOptions;

let docOptions;
if (preprocessOptions) {
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8932,6 +8932,7 @@ __metadata:
"@storybook/node-logger": 6.5.0-rc.1
"@storybook/store": 6.5.0-rc.1
"@types/loader-utils": ^2.0.0
"@types/node": ^14.14.20 || ^16.0.0
"@types/webpack-env": ^1.16.0
core-js: ^3.8.2
global: ^4.4.0
Expand Down

0 comments on commit 50991a6

Please sign in to comment.