Skip to content

Commit

Permalink
Enable relative content paths for the oxide engine (#10621)
Browse files Browse the repository at this point in the history
* enable `relativeContentPathsByDefault` for the `oxide` engine

* update tests to reflect `relative` change in the `oxide` engine

* update changelog
  • Loading branch information
RobinMalfait authored Feb 17, 2023
1 parent c8bf2d4 commit 962eb52
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed

- [Oxide] Disable color opacity plugins by default in the `oxide` engine ([#10618](https://github.com/tailwindlabs/tailwindcss/pull/10618))
- [Oxide] Enable relative content paths for the `oxide` engine ([#10621](https://github.com/tailwindlabs/tailwindcss/pull/10621))

## [3.2.7] - 2023-02-16

Expand Down
3 changes: 3 additions & 0 deletions src/featureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ let defaults = {
get disableColorOpacityUtilitiesByDefault() {
return env.OXIDE
},
get relativeContentPathsByDefault() {
return env.OXIDE
},
}

let featureFlags = {
Expand Down
3 changes: 2 additions & 1 deletion src/util/normalizeConfig.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { flagEnabled } from '../featureFlags'
import log, { dim } from './log'

export function normalizeConfig(config) {
Expand Down Expand Up @@ -189,7 +190,7 @@ export function normalizeConfig(config) {
return content.relative
}

return config.future?.relativeContentPathsByDefault ?? false
return flagEnabled(config, 'relativeContentPathsByDefault')
})(),

files: (() => {
Expand Down
50 changes: 35 additions & 15 deletions tests/normalize-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ crosscheck(({ stable, oxide }) => {

oxide.test.todo('should normalize extractors')
stable.test.each`
config
${{ content: [{ raw: 'text-center' }], purge: { extract: () => ['font-bold'] } }}
${{ content: [{ raw: 'text-center' }], purge: { extract: { DEFAULT: () => ['font-bold'] } } }}
${{
content: [{ raw: 'text-center' }],
purge: { options: { defaultExtractor: () => ['font-bold'] } },
}}
${{
content: [{ raw: 'text-center' }],
purge: { options: { extractors: [{ extractor: () => ['font-bold'], extensions: ['html'] }] } },
}}
${{ content: [{ raw: 'text-center' }], purge: { extract: { html: () => ['font-bold'] } } }}
`('should normalize extractors $config', ({ config }) => {
config
${{ content: [{ raw: 'text-center' }], purge: { extract: () => ['font-bold'] } }}
${{ content: [{ raw: 'text-center' }], purge: { extract: { DEFAULT: () => ['font-bold'] } } }}
${{
content: [{ raw: 'text-center' }],
purge: { options: { defaultExtractor: () => ['font-bold'] } },
}}
${{
content: [{ raw: 'text-center' }],
purge: {
options: { extractors: [{ extractor: () => ['font-bold'], extensions: ['html'] }] },
},
}}
${{ content: [{ raw: 'text-center' }], purge: { extract: { html: () => ['font-bold'] } } }}
`('should normalize extractors $config', ({ config }) => {
return run('@tailwind utilities', config).then((result) => {
return expect(result.css).toMatchFormattedCss(css`
.font-bold {
Expand Down Expand Up @@ -111,12 +113,18 @@ crosscheck(({ stable, oxide }) => {
content: ['./example-folder/**/*.{html,js}'],
}

expect(normalizeConfig(resolveConfig(config)).content).toEqual({
stable.expect(normalizeConfig(resolveConfig(config)).content).toEqual({
files: ['./example-folder/**/*.{html,js}'],
relative: false,
extract: {},
transform: {},
})
oxide.expect(normalizeConfig(resolveConfig(config)).content).toEqual({
files: ['./example-folder/**/*.{html,js}'],
relative: true,
extract: {},
transform: {},
})
})

it('should warn when we detect invalid globs with incorrect brace expansion', () => {
Expand All @@ -130,8 +138,10 @@ crosscheck(({ stable, oxide }) => {
],
}

let normalizedConfig = normalizeConfig(resolveConfig(config)).content

// No rewrite happens
expect(normalizeConfig(resolveConfig(config)).content).toEqual({
stable.expect(normalizedConfig).toEqual({
files: [
'./{example-folder}/**/*.{html,js}',
'./{example-folder}/**/*.{html}',
Expand All @@ -141,6 +151,16 @@ crosscheck(({ stable, oxide }) => {
extract: {},
transform: {},
})
oxide.expect(normalizedConfig).toEqual({
files: [
'./{example-folder}/**/*.{html,js}',
'./{example-folder}/**/*.{html}',
'./example-folder/**/*.{html}',
],
relative: true,
extract: {},
transform: {},
})

// But a warning should happen
expect(spy).toHaveBeenCalledTimes(2)
Expand Down

0 comments on commit 962eb52

Please sign in to comment.