Skip to content

Commit a785c93

Browse files
committed
Try resolving config.default before config to ensure the config file is resolved correctly (#10898)
* try to use `config.default` before using `config` * update changelog * add quick `SHOW_OUTPUT` toggle for integration tests Setting this to `true` shows the output of the executed commands. * add integration tests for `tailwind.config.ts` and `tailwind.config.js` with ESM syntax
1 parent 3809127 commit a785c93

File tree

9 files changed

+719
-18
lines changed

9 files changed

+719
-18
lines changed

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10-
- Nothing yet!
10+
### Fixed
11+
12+
- Try resolving `config.default` before `config` to ensure the config file is resolved correctly ([#10898](https://github.com/tailwindlabs/tailwindcss/pull/10898))
1113

1214
## [3.3.0] - 2023-03-27
1315

integrations/execute.js

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ let path = require('path')
33
let { spawn } = require('child_process')
44
let resolveToolRoot = require('./resolve-tool-root')
55

6+
let SHOW_OUTPUT = false
7+
68
let runningProcessess = []
79

810
afterEach(() => {
@@ -92,13 +94,19 @@ module.exports = function $(command, options = {}) {
9294
let combined = ''
9395

9496
child.stdout.on('data', (data) => {
97+
if (SHOW_OUTPUT) {
98+
console.log(data.toString())
99+
}
95100
stdoutMessages.push(data.toString())
96101
notifyNextStdoutActor()
97102
stdout += data
98103
combined += data
99104
})
100105

101106
child.stderr.on('data', (data) => {
107+
if (SHOW_OUTPUT) {
108+
console.error(data.toString())
109+
}
102110
stderrMessages.push(data.toString())
103111
notifyNextStderrActor()
104112
stderr += data

integrations/parcel/tests/integration.test.js

+130-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ let { css, html, javascript } = require('../../syntax')
33
let { env } = require('../../../lib/lib/sharedState')
44

55
let {
6-
readOutputFile,
76
appendToInputFile,
8-
writeInputFile,
9-
waitForOutputFileCreation,
7+
readOutputFile,
8+
removeFile,
109
waitForOutputFileChange,
10+
waitForOutputFileCreation,
11+
writeInputFile,
1112
} = require('../../io')({ output: 'dist', input: 'src' })
1213

1314
describe('static build', () => {
@@ -32,6 +33,132 @@ describe('static build', () => {
3233
`
3334
)
3435
})
36+
37+
it('can use a tailwind.config.js configuration file with ESM syntax', async () => {
38+
await removeFile('tailwind.config.js')
39+
await writeInputFile(
40+
'index.html',
41+
html`
42+
<link rel="stylesheet" href="./index.css" />
43+
<div class="bg-primary"></div>
44+
`
45+
)
46+
await writeInputFile(
47+
'index.css',
48+
css`
49+
@tailwind base;
50+
@tailwind components;
51+
@tailwind utilities;
52+
`
53+
)
54+
await writeInputFile(
55+
'../tailwind.config.js',
56+
javascript`
57+
export default {
58+
content: ['./src/index.html'],
59+
theme: {
60+
extend: {
61+
colors: {
62+
primary: 'black',
63+
},
64+
},
65+
},
66+
corePlugins: {
67+
preflight: false,
68+
},
69+
}
70+
`
71+
)
72+
73+
await $('parcel build ./src/index.html --no-cache', {
74+
env: { NODE_ENV: 'production' },
75+
})
76+
77+
if (!env.OXIDE) {
78+
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
79+
css`
80+
.bg-primary {
81+
--tw-bg-opacity: 1;
82+
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
83+
}
84+
`
85+
)
86+
}
87+
88+
if (env.OXIDE) {
89+
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
90+
css`
91+
.bg-primary {
92+
background-color: black;
93+
}
94+
`
95+
)
96+
}
97+
})
98+
99+
it('can use a tailwind.config.ts configuration file', async () => {
100+
await removeFile('tailwind.config.js')
101+
await writeInputFile(
102+
'index.html',
103+
html`
104+
<link rel="stylesheet" href="./index.css" />
105+
<div class="bg-primary"></div>
106+
`
107+
)
108+
await writeInputFile(
109+
'index.css',
110+
css`
111+
@tailwind base;
112+
@tailwind components;
113+
@tailwind utilities;
114+
`
115+
)
116+
await writeInputFile(
117+
'../tailwind.config.ts',
118+
javascript`
119+
import type { Config } from 'tailwindcss'
120+
121+
export default {
122+
content: ['./src/index.html'],
123+
theme: {
124+
extend: {
125+
colors: {
126+
primary: 'black',
127+
},
128+
},
129+
},
130+
corePlugins: {
131+
preflight: false,
132+
},
133+
} satisfies Config
134+
`
135+
)
136+
137+
await $('parcel build ./src/index.html --no-cache', {
138+
env: { NODE_ENV: 'production' },
139+
})
140+
141+
if (!env.OXIDE) {
142+
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
143+
css`
144+
.bg-primary {
145+
--tw-bg-opacity: 1;
146+
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
147+
}
148+
`
149+
)
150+
}
151+
152+
if (env.OXIDE) {
153+
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
154+
css`
155+
.bg-primary {
156+
background-color: black;
157+
}
158+
`
159+
)
160+
}
161+
})
35162
})
36163

37164
describe('watcher', () => {

integrations/rollup/tests/integration.test.js

+115-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let $ = require('../../execute')
22
let { css, html, javascript } = require('../../syntax')
33
let { env } = require('../../../lib/lib/sharedState')
44

5-
let { readOutputFile, appendToInputFile, writeInputFile } = require('../../io')({
5+
let { readOutputFile, appendToInputFile, writeInputFile, removeFile } = require('../../io')({
66
output: 'dist',
77
input: 'src',
88
})
@@ -27,6 +27,120 @@ describe('static build', () => {
2727
`
2828
)
2929
})
30+
31+
it('can use a tailwind.config.js configuration file with ESM syntax', async () => {
32+
await removeFile('tailwind.config.js')
33+
await writeInputFile('index.html', html`<div class="bg-primary"></div>`)
34+
await writeInputFile(
35+
'index.css',
36+
css`
37+
@tailwind base;
38+
@tailwind components;
39+
@tailwind utilities;
40+
`
41+
)
42+
await writeInputFile(
43+
'../tailwind.config.js',
44+
javascript`
45+
export default {
46+
content: ['./src/index.html'],
47+
theme: {
48+
extend: {
49+
colors: {
50+
primary: 'black',
51+
},
52+
},
53+
},
54+
corePlugins: {
55+
preflight: false,
56+
},
57+
}
58+
`
59+
)
60+
61+
await $('rollup -c', {
62+
env: { NODE_ENV: 'production' },
63+
})
64+
65+
if (!env.OXIDE) {
66+
expect(await readOutputFile('index.css')).toIncludeCss(
67+
css`
68+
.bg-primary {
69+
--tw-bg-opacity: 1;
70+
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
71+
}
72+
`
73+
)
74+
}
75+
76+
if (env.OXIDE) {
77+
expect(await readOutputFile('index.css')).toIncludeCss(
78+
css`
79+
.bg-primary {
80+
background-color: black;
81+
}
82+
`
83+
)
84+
}
85+
})
86+
87+
it('can use a tailwind.config.ts configuration file', async () => {
88+
await removeFile('tailwind.config.js')
89+
await writeInputFile('index.html', html`<div class="bg-primary"></div>`)
90+
await writeInputFile(
91+
'index.css',
92+
css`
93+
@tailwind base;
94+
@tailwind components;
95+
@tailwind utilities;
96+
`
97+
)
98+
await writeInputFile(
99+
'../tailwind.config.ts',
100+
javascript`
101+
import type { Config } from 'tailwindcss'
102+
103+
export default {
104+
content: ['./src/index.html'],
105+
theme: {
106+
extend: {
107+
colors: {
108+
primary: 'black',
109+
},
110+
},
111+
},
112+
corePlugins: {
113+
preflight: false,
114+
},
115+
} satisfies Config
116+
`
117+
)
118+
119+
await $('rollup -c', {
120+
env: { NODE_ENV: 'production' },
121+
})
122+
123+
if (!env.OXIDE) {
124+
expect(await readOutputFile('index.css')).toIncludeCss(
125+
css`
126+
.bg-primary {
127+
--tw-bg-opacity: 1;
128+
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
129+
}
130+
`
131+
)
132+
}
133+
134+
if (env.OXIDE) {
135+
expect(await readOutputFile('index.css')).toIncludeCss(
136+
css`
137+
.bg-primary {
138+
background-color: black;
139+
}
140+
`
141+
)
142+
}
143+
})
30144
})
31145

32146
describe('watcher', () => {

0 commit comments

Comments
 (0)