File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed
Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ describe('cli', () => {
1010 const customConfigPath = path . resolve ( __dirname , 'fixtures/custom-config.js' )
1111 const defaultConfigFixture = utils . readFile ( constants . defaultConfigStubFile )
1212 const simpleConfigFixture = utils . readFile ( constants . simpleConfigStubFile )
13+ const defaultPostCssConfigFixture = utils . readFile ( constants . defaultPostCssConfigStubFile )
1314
1415 beforeEach ( ( ) => {
1516 console . log = jest . fn ( )
@@ -25,6 +26,17 @@ describe('cli', () => {
2526 } )
2627 } )
2728
29+ it ( 'creates a Tailwind config file and a postcss.config.js file' , ( ) => {
30+ return runInTempDirectory ( ( ) => {
31+ return cli ( [ 'init' , '-p' ] ) . then ( ( ) => {
32+ expect ( utils . readFile ( constants . defaultConfigFile ) ) . toEqual ( simpleConfigFixture )
33+ expect ( utils . readFile ( constants . defaultPostCssConfigFile ) ) . toEqual (
34+ defaultPostCssConfigFixture
35+ )
36+ } )
37+ } )
38+ } )
39+
2840 it ( 'creates a full Tailwind config file' , ( ) => {
2941 return runInTempDirectory ( ( ) => {
3042 return cli ( [ 'init' , '--full' ] ) . then ( ( ) => {
Original file line number Diff line number Diff line change @@ -13,10 +13,15 @@ export const options = [
1313 usage : '--full' ,
1414 description : 'Generate complete configuration file.' ,
1515 } ,
16+ {
17+ usage : '-p' ,
18+ description : 'Generate a postcss configuration file.' ,
19+ } ,
1620]
1721
1822export const optionMap = {
1923 full : [ 'full' ] ,
24+ postcss : [ 'p' ] ,
2025}
2126
2227/**
@@ -43,6 +48,14 @@ export function run(cliParams, cliOptions) {
4348 utils . log ( )
4449 utils . log ( emoji . yes , 'Created Tailwind config file:' , colors . file ( simplePath ) )
4550
51+ if ( cliOptions . postcss ) {
52+ const path = utils . getSimplePath ( constants . defaultPostCssConfigFile )
53+ utils . exists ( constants . defaultPostCssConfigFile ) &&
54+ utils . die ( colors . file ( path ) , 'already exists.' )
55+ utils . copyFile ( constants . defaultPostCssConfigStubFile , constants . defaultPostCssConfigFile )
56+ utils . log ( emoji . yes , 'Created PostCSS config file:' , colors . file ( path ) )
57+ }
58+
4659 utils . footer ( )
4760
4861 resolve ( )
Original file line number Diff line number Diff line change @@ -2,5 +2,11 @@ import path from 'path'
22
33export const cli = 'tailwind'
44export const defaultConfigFile = './tailwind.config.js'
5+ export const defaultPostCssConfigFile = './postcss.config.js'
6+
57export const defaultConfigStubFile = path . resolve ( __dirname , '../stubs/defaultConfig.stub.js' )
68export const simpleConfigStubFile = path . resolve ( __dirname , '../stubs/simpleConfig.stub.js' )
9+ export const defaultPostCssConfigStubFile = path . resolve (
10+ __dirname ,
11+ '../stubs/defaultPostCssConfig.stub.js'
12+ )
Original file line number Diff line number Diff line change 1+ module . exports = {
2+ plugins : {
3+ tailwindcss : { } ,
4+ autoprefixer : { } ,
5+ } ,
6+ }
7+
You can’t perform that action at this time.
0 commit comments