Skip to content

Instantly share code, notes, and snippets.

@javascripter
Created November 26, 2024 12:10
Show Gist options
  • Save javascripter/17f0fe9cc54cca0087c273aecc4412a6 to your computer and use it in GitHub Desktop.
Save javascripter/17f0fe9cc54cca0087c273aecc4412a6 to your computer and use it in GitHub Desktop.
Next.js + Turbopack + PostCSS example
// next.config.mjs
import type { NextConfig } from 'next'
function getBabelLoader() {
return {
loader: 'babel-loader',
options: {
presets: [
[
'next/dist/compiled/babel/preset-typescript',
{
allowNamespaces: true,
},
],
[
'react-strict-dom/babel-preset',
{
debug: true,
dev: process.env.NODE_ENV === 'development',
rootDir: process.cwd(),
},
],
],
},
}
}
const nextConfig: NextConfig = {
transpilePackages: ['react-strict-dom'],
webpack: (config) => {
config.module.rules.push({
test: /\.(js|jsx|ts|tsx)$/,
use: [getBabelLoader()],
})
return config
},
experimental: {
turbo: {
rules: {
'*.{js,jsx,ts,tsx}': {
loaders: [getBabelLoader()],
},
},
},
},
}
export default nextConfig
export default {
plugins: {
'postcss-react-strict-dom': {
include: ['src/**/*.{js,jsx,ts,tsx}'],
babelConfig: {
babelrc: false,
presets: [
[
'next/dist/compiled/babel/preset-typescript',
{
allowNamespaces: true,
},
],
[
'react-strict-dom/babel-preset',
{
debug: true,
dev: process.env.NODE_ENV === 'development',
rootDir: process.cwd(),
},
],
],
},
},
autoprefixer: {},
},
}
@MoOx
Copy link

MoOx commented Apr 16, 2025

Thank you so much for all the explanations ! Some of this should be in RSD doc for sure !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment