Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import type { StorybookConfig } from '@storybook/nextjs'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path')

module.exports = {
stories: ['../!(node_modules)/**/*.stories.@(js|jsx|ts|tsx)'],
stories: ['../**/*.stories.@(js|jsx|ts|tsx)'],
staticDirs: ['../public'],
addons: [
'@storybook/addon-links',
Expand All @@ -11,9 +13,20 @@ module.exports = {
],
framework: {
name: '@storybook/nextjs',
options: {}
options: {
// Ensure Storybook uses Next.js config (sassOptions, images, etc.)
nextConfigPath: path.resolve(__dirname, '../next.config.mjs')
}
},
async webpackFinal(config) {
// Resolve SCSS imports like `@use 'styles/utils'`
config.resolve = config.resolve || {}
config.resolve.alias = {
...(config.resolve.alias || {}),
styles: path.resolve(__dirname, '../styles')
}

// Keep the custom .md loader used by content stories
config.module?.rules?.push({
test: /\.md$/,
loader: require.resolve('./loaders/dist/postLoader'),
Expand Down
18 changes: 11 additions & 7 deletions next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import withBundleAnalyzer from '@next/bundle-analyzer'
import path from 'node:path'

/**
* @type {import('next').NextConfig}
Expand All @@ -8,6 +9,10 @@ const config = {
// https://nextjs.org/docs/basic-features/eslint#linting-custom-directories-and-files
dirs: ['.']
},
sassOptions: {
// Allow Sass imports like `@use 'utils'` from the styles directory
includePaths: [path.join(process.cwd(), 'styles')]
},
typescript: {
ignoreBuildErrors: true
},
Expand All @@ -21,10 +26,9 @@ const config = {
}
}

// eslint-disable-next-line import/no-anonymous-default-export
export default () =>
[
withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true'
})
].reduce((acc, next) => next(acc), config)
// Compose Next.js plugins and export the final config object
export default [
withBundleAnalyzer({
enabled: process.env.ANALYZE === 'true'
})
].reduce((acc, next) => next(acc), config)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"analyze": "ANALYZE=true npm run build",
"export": "next export",
"start": "next start",
"sb": "npm run sb:prepare && storybook dev -p 6006",
"sb": "npm run sb:prepare && storybook dev -p 6006 --no-open",
"sb:prepare": "node .storybook/loaders/build.js",
"sb:build": "npm run sb:prepare && storybook build",
"sb:serve": "npx serve storybook-static",
Expand Down
Loading