@@ -22,7 +22,6 @@ interface TailwindConfig {
22
22
interface GenerateTailwindcssOpts {
23
23
cwd : string ;
24
24
tmpPath : string ;
25
- config : Config [ 'tailwindcss' ] ;
26
25
mode : 'development' | 'production' ;
27
26
}
28
27
@@ -69,44 +68,29 @@ function getTailwindBinPath(opts: { cwd: string }): string {
69
68
export async function generateTailwindcss (
70
69
opts : GenerateTailwindcssOpts ,
71
70
) : Promise < string > {
72
- const { cwd, tmpPath, config , mode } = opts ;
71
+ const { cwd, tmpPath, mode } = opts ;
73
72
const rootPath = path . join ( tmpPath , 'tailwindcss' ) ;
74
73
75
74
// 设置文件路径
76
75
const paths = {
77
- input : path . join ( rootPath , 'tailwindDirectives .css' ) ,
76
+ input : path . join ( cwd , 'src/tailwind .css' ) ,
78
77
output : path . join ( rootPath , 'tailwind.css' ) ,
79
- config : path . join ( rootPath , 'tailwind.config.js' ) ,
78
+ config : path . join ( cwd , 'tailwind.config.js' ) ,
80
79
} ;
81
80
82
- // 默认 Tailwind 配置
83
- const defaultConfig : TailwindConfig = {
84
- content : [
85
- './src/pages/**/*.{js,ts,jsx,tsx}' ,
86
- './src/components/**/*.{js,ts,jsx,tsx}' ,
87
- ] ,
88
- } ;
89
-
90
- const mergedConfig = { ...defaultConfig , ...config } ;
91
-
92
- // 确保目录存在
93
- fs . mkdirpSync ( path . dirname ( paths . input ) ) ;
94
-
95
- // 写入 Tailwind 指令文件
96
- fs . writeFileSync (
97
- paths . input ,
98
- `
99
- @tailwind base;
100
- @tailwind components;
101
- @tailwind utilities;
102
- ` . trim ( ) ,
103
- ) ;
81
+ if ( ! fs . existsSync ( paths . input ) ) {
82
+ console . log (
83
+ 'Enabling feature tailwindcss requires input file src/tailwind.css' ,
84
+ ) ;
85
+ return '' ;
86
+ }
104
87
105
- // 写入配置文件
106
- fs . writeFileSync (
107
- paths . config ,
108
- `export default ${ JSON . stringify ( mergedConfig , null , 2 ) } ` ,
109
- ) ;
88
+ if ( ! fs . existsSync ( paths . config ) ) {
89
+ console . log (
90
+ 'Enabling feature tailwindcss requires config file tailwind.config.js' ,
91
+ ) ;
92
+ return '' ;
93
+ }
110
94
111
95
// 生成 CSS 文件
112
96
await generateFile ( {
0 commit comments