histoire
Version:
A fast story book powered by Vite
152 lines (151 loc) • 4.98 kB
JavaScript
import { HISTOIRE_MATRIX_NUMERIC_VALUES } from '@histoire/protocol';
import { DEFAULT_THEME_FONTS } from '@histoire/shared';
import { tailwindTokens } from '../builtin-plugins/tailwind-tokens.js';
import { vanillaSupport } from '../builtin-plugins/vanilla-support/plugin.js';
import { defaultColors } from '../colors.js';
import { DEFAULT_COLLECT_TIMEOUT, DEFAULT_STORY_COLLECT_TIMEOUT } from '../util/test-timeouts.js';
/**
* Builds a fresh default Histoire configuration.
*
* A new object every call: the returned config is mutated in place by the
* plugin `defaultConfig` hooks and by `processConfig`.
*/
export function getDefaultConfig() {
return {
plugins: [
vanillaSupport(),
tailwindTokens(),
],
outDir: '.histoire/dist',
mcp: true,
browser: { source: 'auto' },
embed: { enabled: false, allowedOrigins: [], channels: [], allowOpenInEditor: false, allowServerTests: false },
storyMatch: [
'**/*.story.vue',
'**/*.story.svelte',
],
storyIgnored: [
'**/node_modules/**',
'**/dist/**',
],
supportMatch: [],
tree: {
file: 'title',
order: 'asc',
},
theme: {
title: 'Histoire',
fonts: { ...DEFAULT_THEME_FONTS },
colors: {
primary: defaultColors.emerald,
gray: defaultColors.zinc,
},
defaultColorScheme: 'auto',
storeColorScheme: true,
darkClass: 'dark',
},
ui: { defaultArrange: 'grid', frameBudget: 6, matrix: { numericValues: [...HISTOIRE_MATRIX_NUMERIC_VALUES] } },
agents: { enabled: false, presets: [], permissions: { fileEdits: 'ask', terminal: 'ask' } },
// `enabled` gates pinned threads only; `file` is the legacy source imported into threads.json.
comments: { enabled: true },
responsivePresets: [
{
label: 'Mobile (Small)',
width: 320,
height: 560,
},
{
label: 'Mobile (Medium)',
width: 360,
height: 640,
},
{
label: 'Mobile (Large)',
width: 414,
height: 896,
},
{
label: 'Tablet',
width: 768,
height: 1024,
},
{
label: 'Laptop (Small)',
width: 1024,
height: null,
},
{
label: 'Laptop (Large)',
width: 1366,
height: null,
},
{
label: 'Desktop',
width: 1920,
height: null,
},
{
label: '4K',
width: 3840,
height: null,
},
],
backgroundPresets: [
{
label: 'Transparent',
color: 'transparent',
contrastColor: '#333',
},
{
label: 'White',
color: '#fff',
contrastColor: '#333',
},
{
label: 'Light gray',
color: '#aaa',
contrastColor: '#000',
},
{
label: 'Dark gray',
color: '#333',
contrastColor: '#fff',
},
{
label: 'Black',
color: '#000',
contrastColor: '#eee',
},
],
routerMode: 'history',
build: {
target: 'static',
node: { includeSource: true },
excludeFromVendorsChunk: [],
},
test: {
buildCollection: 'hybrid',
collectTimeout: DEFAULT_COLLECT_TIMEOUT,
storyCollectTimeout: DEFAULT_STORY_COLLECT_TIMEOUT,
// `runStallTimeout` is resolved in `processConfig`: a default here would hide the deprecated `runTimeout`.
// `maxWorkers` is resolved per run: its default depends on the memory available then.
},
vite: (config) => {
// Remove vite:legacy plugins https://github.com/histoire-dev/histoire/issues/156
const index = config.plugins?.findIndex(plugin => Array.isArray(plugin)
&& typeof plugin[0] === 'object'
&& !Array.isArray(plugin[0])
// @ts-expect-error could have no property 'name'
&& plugin[0].name?.startsWith('vite:legacy'));
if (index !== -1) {
config.plugins?.splice(index, 1);
}
return {
build: {
lib: false,
},
};
},
viteIgnorePlugins: [],
};
}