@@ -2,7 +2,7 @@ import fs from 'fs'
22import path from 'path'
33import postcss from 'postcss'
44import tailwind from '../src/index'
5- import { defaultConfigFile } from '../src/constants'
5+ import { cjsConfigFile , defaultConfigFile } from '../src/constants'
66import inTempDirectory from '../jest/runInTempDirectory'
77
88test ( 'it uses the values from the custom config file' , ( ) => {
@@ -133,6 +133,45 @@ test('custom config can be passed under the `config` property', () => {
133133 } )
134134} )
135135
136+ test ( 'tailwind.config.cjs is picked up by default' , ( ) => {
137+ return inTempDirectory ( ( ) => {
138+ fs . writeFileSync (
139+ path . resolve ( cjsConfigFile ) ,
140+ `module.exports = {
141+ theme: {
142+ screens: {
143+ mobile: '400px',
144+ },
145+ },
146+ }`
147+ )
148+
149+ return postcss ( [ tailwind ] )
150+ . process (
151+ `
152+ @responsive {
153+ .foo {
154+ color: blue;
155+ }
156+ }
157+ ` ,
158+ { from : undefined }
159+ )
160+ . then ( ( result ) => {
161+ expect ( result . css ) . toMatchCss ( `
162+ .foo {
163+ color: blue;
164+ }
165+ @media (min-width: 400px) {
166+ .mobile\\:foo {
167+ color: blue;
168+ }
169+ }
170+ ` )
171+ } )
172+ } )
173+ } )
174+
136175test ( 'tailwind.config.js is picked up by default' , ( ) => {
137176 return inTempDirectory ( ( ) => {
138177 fs . writeFileSync (
@@ -172,6 +211,45 @@ test('tailwind.config.js is picked up by default', () => {
172211 } )
173212} )
174213
214+ test ( 'tailwind.config.cjs is picked up by default when passing an empty object' , ( ) => {
215+ return inTempDirectory ( ( ) => {
216+ fs . writeFileSync (
217+ path . resolve ( cjsConfigFile ) ,
218+ `module.exports = {
219+ theme: {
220+ screens: {
221+ mobile: '400px',
222+ },
223+ },
224+ }`
225+ )
226+
227+ return postcss ( [ tailwind ( { } ) ] )
228+ . process (
229+ `
230+ @responsive {
231+ .foo {
232+ color: blue;
233+ }
234+ }
235+ ` ,
236+ { from : undefined }
237+ )
238+ . then ( ( result ) => {
239+ expect ( result . css ) . toMatchCss ( `
240+ .foo {
241+ color: blue;
242+ }
243+ @media (min-width: 400px) {
244+ .mobile\\:foo {
245+ color: blue;
246+ }
247+ }
248+ ` )
249+ } )
250+ } )
251+ } )
252+
175253test ( 'tailwind.config.js is picked up by default when passing an empty object' , ( ) => {
176254 return inTempDirectory ( ( ) => {
177255 fs . writeFileSync (
0 commit comments