@nx/nuxt
Version:
38 lines (37 loc) • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.storybookConfigurationGenerator = storybookConfigurationGenerator;
const devkit_1 = require("@nx/devkit");
const vue_1 = require("@nx/vue");
/*
* This generator is basically the Vue one, but for Nuxt we
* are just adding the styles in `.storybook/preview.ts`
*/
async function storybookConfigurationGenerator(tree, options) {
const { root, sourceRoot } = (0, devkit_1.readProjectConfiguration)(tree, options.project);
// Determine the source directory (app/ for Nuxt v4, src/ for Nuxt v3)
const sourceDir = sourceRoot?.endsWith('/app')
? 'app'
: sourceRoot?.endsWith('/src')
? 'src'
: 'src'; // default to src for backward compatibility
const storybookConfigurationGenerator = await (0, vue_1.storybookConfigurationGenerator)(tree, {
...options,
addPlugin: true,
});
// Default tsConfiguration to true to match schema default
const tsConfiguration = options.tsConfiguration ?? true;
// Write the preview file after the base storybook configuration is set up
// This ensures we overwrite any default content with our Nuxt-specific import
tree.write((0, devkit_1.joinPathFragments)(root, '.storybook', 'preview.' + (tsConfiguration ? 'ts' : 'js')), `import '../${sourceDir}/assets/css/styles.css';`);
(0, devkit_1.updateJson)(tree, `${root}/tsconfig.storybook.json`, (json) => {
json.compilerOptions = {
...json.compilerOptions,
composite: true,
};
return json;
});
await (0, devkit_1.formatFiles)(tree);
return (0, devkit_1.runTasksInSerial)(storybookConfigurationGenerator);
}
exports.default = storybookConfigurationGenerator;