Skip to content

Commit

Permalink
Support Vite in Svelte generator
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Jul 13, 2022
1 parent 3929b4a commit cfd34ac
Showing 1 changed file with 1 addition and 31 deletions.
32 changes: 1 addition & 31 deletions lib/cli/src/generators/SVELTE/index.ts
Original file line number Diff line number Diff line change
@@ -1,39 +1,9 @@
import fse from 'fs-extra';
import { logger } from '@storybook/node-logger';

import { baseGenerator, Generator } from '../baseGenerator';

const generator: Generator = async (packageManager, npmOptions, options) => {
let extraMain;
// svelte.config.js ?
if (fse.existsSync('./svelte.config.js')) {
logger.info("Configuring preprocessor from 'svelte.config.js'");

extraMain = {
svelteOptions: { preprocess: '%%require("../svelte.config.js").preprocess%%' },
};
} else if (fse.existsSync('./svelte.config.cjs')) {
logger.info("Configuring preprocessor from 'svelte.config.cjs'");

extraMain = {
svelteOptions: { preprocess: '%%require("../svelte.config.cjs").preprocess%%' },
};
} else {
// svelte-preprocess dependencies ?
const packageJson = packageManager.retrievePackageJson();
if (packageJson.devDependencies && packageJson.devDependencies['svelte-preprocess']) {
logger.info("Configuring preprocessor with 'svelte-preprocess'");

extraMain = {
svelteOptions: { preprocess: '%%require("svelte-preprocess")()%%' },
};
}
}

await baseGenerator(packageManager, npmOptions, options, 'svelte', {
extraPackages: ['svelte', 'svelte-loader'],
extraPackages: ['@storybook/addon-svelte-csf'],
extensions: ['js', 'jsx', 'ts', 'tsx', 'svelte'],
extraMain,
commonJs: true,
});
};
Expand Down

0 comments on commit cfd34ac

Please sign in to comment.