File tree Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Expand file tree Collapse file tree 3 files changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ let commands = {
151151 args : {
152152 '--full' : { type : Boolean , description : 'Initialize a full `tailwind.config.js` file' } ,
153153 '--postcss' : { type : Boolean , description : 'Initialize a `postcss.config.js` file' } ,
154+ '--types' : {
155+ type : Boolean ,
156+ description : 'Add TypeScript types for the `tailwind.config.js` file' ,
157+ } ,
154158 '-f' : '--full' ,
155159 '-p' : '--postcss' ,
156160 } ,
209213 help ( {
210214 usage : [
211215 'tailwindcss [--input input.css] [--output output.css] [--watch] [options...]' ,
212- 'tailwindcss init [--full] [--postcss] [options...]' ,
216+ 'tailwindcss init [--full] [--postcss] [--types] [ options...]' ,
213217 ] ,
214218 commands : Object . keys ( commands )
215219 . filter ( ( command ) => command !== 'build' )
@@ -336,6 +340,13 @@ function init() {
336340 'utf8'
337341 )
338342
343+ if ( args [ '--types' ] ) {
344+ let typesHeading = "/** @type {import('tailwindcss/types').Config} */"
345+ stubFile =
346+ stubFile . replace ( `module.exports = ` , `${ typesHeading } \nconst config = ` ) +
347+ '\nmodule.exports = config'
348+ }
349+
339350 // Change colors import
340351 stubFile = stubFile . replace ( '../colors' , 'tailwindcss/colors' )
341352
Original file line number Diff line number Diff line change 1- /** @type {import('tailwindcss/types').Config } */
2- const config = {
1+ module . exports = {
32 content : [ ] ,
43 presets : [ ] ,
54 darkMode : 'media' , // or 'class'
@@ -952,5 +951,3 @@ const config = {
952951 ] ,
953952 plugins : [ ] ,
954953}
955-
956- module . exports = config
Original file line number Diff line number Diff line change 1- /** @type {import('tailwindcss/types').Config } */
2- const config = {
1+ module . exports = {
32 content : [ ] ,
43 theme : {
54 extend : { } ,
65 } ,
76 plugins : [ ] ,
87}
9-
10- module . exports = config
You can’t perform that action at this time.
0 commit comments