Created
November 26, 2024 12:10
-
-
Save javascripter/17f0fe9cc54cca0087c273aecc4412a6 to your computer and use it in GitHub Desktop.
Next.js + Turbopack + PostCSS example
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
// 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 |
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
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: {}, | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much for all the explanations ! Some of this should be in RSD doc for sure !