mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
bf6784f78b
### What? Adds support for TypeScript PostCSS configuration files in Turbopack. ### Why? Users can write their PostCSS configuration in TypeScript for better type safety and IDE support. This was already supported in webpack but was missing in Turbopack. ### How? Added the following TypeScript config file names to Turbopack's PostCSS config detection: - `postcss.config.ts`, `postcss.config.mts`, `postcss.config.cts` - `.postcssrc.ts`, `.postcssrc.mts`, `.postcssrc.cts` - `.config/postcssrc.ts`, `.config/postcssrc.mts`, `.config/postcssrc.cts` Also updated the Turbopack documentation to reflect the supported config file extensions (`.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`). ### Testing Added e2e tests that verify the TypeScript PostCSS config is actually loaded and applied by using a custom plugin that transforms colors. Tests cover: - `postcss.config.ts` - `postcss.config.mts` - `postcss.config.cts` - `.postcssrc.ts`
20 lines
422 B
TypeScript
20 lines
422 B
TypeScript
// Custom PostCSS plugin that transforms color: red to color: green
|
|
// This allows us to verify that the PostCSS config is actually being applied
|
|
|
|
const plugin = () => {
|
|
return {
|
|
postcssPlugin: 'color-transform',
|
|
Declaration: {
|
|
color(decl: { value: string }) {
|
|
if (decl.value === 'red') {
|
|
decl.value = 'green'
|
|
}
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
plugin.postcss = true
|
|
|
|
export default plugin
|