Skip to content

Commit

Permalink
fix(nextjs): adjust .babelrc for Next libraries with emotion styling
Browse files Browse the repository at this point in the history
  • Loading branch information
juristr committed Aug 19, 2021
1 parent 28ebfae commit 2f3742b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions packages/next/src/generators/library/library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ describe('next library', () => {
});
expect(readJson(appTree, 'libs/my-lib2/.babelrc')).toEqual({
presets: [
'next/babel',
{
'preset-react': {
importSource: '@emotion/react',
[
'next/babel',
{
'preset-react': {
importSource: '@emotion/react',
},
},
},
],
],
plugins: ['@emotion/babel-plugin'],
});
Expand Down
12 changes: 7 additions & 5 deletions packages/next/src/generators/library/library.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export async function libraryGenerator(host: Tree, options: Schema) {
updateJson(host, joinPathFragments(projectRoot, '.babelrc'), (json) => {
if (options.style === '@emotion/styled') {
json.presets = [
'next/babel',
{
'preset-react': {
importSource: '@emotion/react',
[
'next/babel',
{
'preset-react': {
importSource: '@emotion/react',
},
},
},
],
];
} else if (options.style === 'styled-jsx') {
// next.js doesn't require the `styled-jsx/babel' plugin as it is already
Expand Down

0 comments on commit 2f3742b

Please sign in to comment.