Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try resolving config.default before config to ensure the config file is resolved correctly #10898

Merged
merged 4 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

- Nothing yet!
### Fixed

- Try resolving `config.default` before `config` to ensure the config file is resolved correctly ([#10898](https://github.com/tailwindlabs/tailwindcss/pull/10898))

## [3.3.0] - 2023-03-27

Expand Down
8 changes: 8 additions & 0 deletions integrations/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ let path = require('path')
let { spawn } = require('child_process')
let resolveToolRoot = require('./resolve-tool-root')

let SHOW_OUTPUT = false

let runningProcessess = []

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

child.stdout.on('data', (data) => {
if (SHOW_OUTPUT) {
console.log(data.toString())
}
stdoutMessages.push(data.toString())
notifyNextStdoutActor()
stdout += data
combined += data
})

child.stderr.on('data', (data) => {
if (SHOW_OUTPUT) {
console.error(data.toString())
}
stderrMessages.push(data.toString())
notifyNextStderrActor()
stderr += data
Expand Down
133 changes: 130 additions & 3 deletions integrations/parcel/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ let { css, html, javascript } = require('../../syntax')
let { env } = require('../../../lib/lib/sharedState')

let {
readOutputFile,
appendToInputFile,
writeInputFile,
waitForOutputFileCreation,
readOutputFile,
removeFile,
waitForOutputFileChange,
waitForOutputFileCreation,
writeInputFile,
} = require('../../io')({ output: 'dist', input: 'src' })

describe('static build', () => {
Expand All @@ -32,6 +33,132 @@ describe('static build', () => {
`
)
})

it('can use a tailwind.config.js configuration file with ESM syntax', async () => {
await removeFile('tailwind.config.js')
await writeInputFile(
'index.html',
html`
<link rel="stylesheet" href="./index.css" />
<div class="bg-primary"></div>
`
)
await writeInputFile(
'index.css',
css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`
)
await writeInputFile(
'../tailwind.config.js',
javascript`
export default {
content: ['./src/index.html'],
theme: {
extend: {
colors: {
primary: 'black',
},
},
},
corePlugins: {
preflight: false,
},
}
`
)

await $('parcel build ./src/index.html --no-cache', {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
--tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
}
`
)
}

if (env.OXIDE) {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
background-color: black;
}
`
)
}
})

it('can use a tailwind.config.ts configuration file', async () => {
await removeFile('tailwind.config.js')
await writeInputFile(
'index.html',
html`
<link rel="stylesheet" href="./index.css" />
<div class="bg-primary"></div>
`
)
await writeInputFile(
'index.css',
css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`
)
await writeInputFile(
'../tailwind.config.ts',
javascript`
import type { Config } from 'tailwindcss'

export default {
content: ['./src/index.html'],
theme: {
extend: {
colors: {
primary: 'black',
},
},
},
corePlugins: {
preflight: false,
},
} satisfies Config
`
)

await $('parcel build ./src/index.html --no-cache', {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
--tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
}
`
)
}

if (env.OXIDE) {
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(
css`
.bg-primary {
background-color: black;
}
`
)
}
})
})

describe('watcher', () => {
Expand Down
116 changes: 115 additions & 1 deletion integrations/rollup/tests/integration.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let $ = require('../../execute')
let { css, html, javascript } = require('../../syntax')
let { env } = require('../../../lib/lib/sharedState')

let { readOutputFile, appendToInputFile, writeInputFile } = require('../../io')({
let { readOutputFile, appendToInputFile, writeInputFile, removeFile } = require('../../io')({
output: 'dist',
input: 'src',
})
Expand All @@ -27,6 +27,120 @@ describe('static build', () => {
`
)
})

it('can use a tailwind.config.js configuration file with ESM syntax', async () => {
await removeFile('tailwind.config.js')
await writeInputFile('index.html', html`<div class="bg-primary"></div>`)
await writeInputFile(
'index.css',
css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`
)
await writeInputFile(
'../tailwind.config.js',
javascript`
export default {
content: ['./src/index.html'],
theme: {
extend: {
colors: {
primary: 'black',
},
},
},
corePlugins: {
preflight: false,
},
}
`
)

await $('rollup -c', {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
--tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
}
`
)
}

if (env.OXIDE) {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
background-color: black;
}
`
)
}
})

it('can use a tailwind.config.ts configuration file', async () => {
await removeFile('tailwind.config.js')
await writeInputFile('index.html', html`<div class="bg-primary"></div>`)
await writeInputFile(
'index.css',
css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`
)
await writeInputFile(
'../tailwind.config.ts',
javascript`
import type { Config } from 'tailwindcss'

export default {
content: ['./src/index.html'],
theme: {
extend: {
colors: {
primary: 'black',
},
},
},
corePlugins: {
preflight: false,
},
} satisfies Config
`
)

await $('rollup -c', {
env: { NODE_ENV: 'production' },
})

if (!env.OXIDE) {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
--tw-bg-opacity: 1;
background-color: rgb(0 0 0 / var(--tw-bg-opacity));
}
`
)
}

if (env.OXIDE) {
expect(await readOutputFile('index.css')).toIncludeCss(
css`
.bg-primary {
background-color: black;
}
`
)
}
})
})

describe('watcher', () => {
Expand Down
Loading