pradel / create-react-app-esbuild

Use esbuild in your create-react-app for faster compilation, development and tests
MIT License
563 stars 35 forks source link

craco babel settings not working @emotion/react #61

Closed leesuhyung closed 2 years ago

leesuhyung commented 2 years ago
// emotion css prop is not working
module.exports = {
  babel: {
    presets: [
      [
        '@babel/preset-react',
        {'runtime': 'automatic', 'importSource': '@emotion/react'}
      ]
    ],
    plugins: ['@emotion/babel-plugin']
  },
  plugins: [
    {
      plugin: CracoEsbuildPlugin,
    },
    ...
  ],
}

// it works
module.exports = {
  babel: {
    presets: [
      [
        '@babel/preset-react',
        {'runtime': 'automatic', 'importSource': '@emotion/react'}
      ]
    ],
    plugins: ['@emotion/babel-plugin']
  },
  ... // use the default babel settings of react-script instead of esbuild
}

When I use craco esbuild, cannot use css props in emotion. Is the craco esbuild plugin clearing babel settings?

pradel commented 2 years ago

Yes, esbuild is replacing babel totally.

leesuhyung commented 2 years ago

@pradel Sorry to bother you, is there any way to use babel preset while using esbuild?

pradel commented 2 years ago

Maybe there you can see how but I never did this https://github.com/privatenumber/esbuild-loader/issues/99