-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24852 from storybookjs/valentin/add-swc-support-f…
…or-nextjs Next.js: Add experimental SWC support
- Loading branch information
Showing
35 changed files
with
617 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 19 additions & 11 deletions
30
code/frameworks/nextjs/src/font/webpack/configureNextFont.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,22 @@ | ||
import type { Configuration } from 'webpack'; | ||
|
||
export function configureNextFont(baseConfig: Configuration) { | ||
baseConfig.plugins = [...(baseConfig.plugins || [])]; | ||
baseConfig.resolveLoader = { | ||
...baseConfig.resolveLoader, | ||
alias: { | ||
...baseConfig.resolveLoader?.alias, | ||
'storybook-nextjs-font-loader': require.resolve( | ||
'./font/webpack/loader/storybook-nextjs-font-loader' | ||
), | ||
}, | ||
}; | ||
export function configureNextFont(baseConfig: Configuration, isSWC?: boolean) { | ||
const fontLoaderPath = require.resolve( | ||
'@storybook/nextjs/font/webpack/loader/storybook-nextjs-font-loader' | ||
); | ||
|
||
if (isSWC) { | ||
baseConfig.module?.rules?.push({ | ||
test: /next\/.*\/target.css$/, | ||
loader: fontLoaderPath, | ||
}); | ||
} else { | ||
baseConfig.resolveLoader = { | ||
...baseConfig.resolveLoader, | ||
alias: { | ||
...baseConfig.resolveLoader?.alias, | ||
'storybook-nextjs-font-loader': fontLoaderPath, | ||
}, | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.