-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathindex.js
More file actions
61 lines (55 loc) · 1.45 KB
/
index.js
File metadata and controls
61 lines (55 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { svelteIndexer } from './indexer.js';
export function managerEntries(entry = []) {
return [...entry, require.resolve('./manager')];
}
export function webpack(config) {
return {
...config,
module: {
...config.module,
rules: [
...config.module.rules,
{
test: /\.stories\.svelte$/,
enforce: 'post',
use: [
{
loader: require.resolve('../parser/svelte-stories-loader'),
},
],
},
],
},
};
}
export async function viteFinal(config, options) {
const { plugins = [] } = config;
const svelteOptions = await options.presets.apply('svelteOptions', {}, options);
let svelteConfig = svelteOptions;
try {
const { loadSvelteConfig } = await import('@sveltejs/vite-plugin-svelte');
svelteConfig = { ...(await loadSvelteConfig()), ...svelteOptions };
} catch (err) {
const { log } = console;
if (err.code === 'MODULE_NOT_FOUND') {
log('@sveltejs/vite-plugin-svelte not found. Unable to load config from svelte.config file');
} else {
throw err;
}
}
const svelteCsfPlugin = (await import('../plugins/vite-svelte-csf.js')).default.default;
plugins.push(svelteCsfPlugin(svelteConfig));
return {
...config,
plugins,
};
}
export const storyIndexers = async (indexers) => {
return [
{
test: /\.stories\.svelte$/,
indexer: svelteIndexer,
},
...(indexers || []),
];
};