@@ -2,7 +2,7 @@ import fs from 'fs'
2
2
import path from 'path'
3
3
import postcss from 'postcss'
4
4
import tailwind from '../src/index'
5
- import { defaultConfigFile } from '../src/constants'
5
+ import { cjsConfigFile , defaultConfigFile } from '../src/constants'
6
6
import inTempDirectory from '../jest/runInTempDirectory'
7
7
8
8
test ( 'it uses the values from the custom config file' , ( ) => {
@@ -133,6 +133,45 @@ test('custom config can be passed under the `config` property', () => {
133
133
} )
134
134
} )
135
135
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
+
136
175
test ( 'tailwind.config.js is picked up by default' , ( ) => {
137
176
return inTempDirectory ( ( ) => {
138
177
fs . writeFileSync (
@@ -172,6 +211,45 @@ test('tailwind.config.js is picked up by default', () => {
172
211
} )
173
212
} )
174
213
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
+
175
253
test ( 'tailwind.config.js is picked up by default when passing an empty object' , ( ) => {
176
254
return inTempDirectory ( ( ) => {
177
255
fs . writeFileSync (
0 commit comments