Skip to content

Conversation

@RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Sep 30, 2021

This PR will normalize the config from the old structures to the new structure. If we detect that anything is old/incorrect, we are still able to normalize it but we will also warn in the console.

We will have to improve the warning to include a link to a discussion / website to talk about the new structure.
If you happen to see this PR, here is the new structure:

module.exports = {
  content: { // Or content: ['/path-to-files', '/path-to-files-with-globs/**.js', { raw: 'text-center' }]
    files: [/* Same as above... */],
    extract: { // Or a function immediately for the DEFAULT case
      DEFAULT: (content) => ['list', 'of', 'candidates']
      html: (content) => ['list', 'of', 'candidates']
    },
    transform: { // Or a function immediately for the DEFAULT case
      DEFAULT: (content) => content,
      md: (content) => parseMarkdown(content)
    }
  },
  safelist: [
    'mt-20', // Raw strings
    { pattern: /bg-red/, variants: ['hover', 'focus'] }
  ]
}

TODO:

  • upgrade existing tests to "new" syntax
  • add a "old" tailwind config to make sure that everything still works in v3 + warning

@RobinMalfait RobinMalfait force-pushed the handle-proper-fallbacks-in-config branch from 3f03889 to 093db28 Compare September 30, 2021 16:28
@RobinMalfait RobinMalfait changed the title handle proper fallbacks in config Handle proper fallbacks in config Sep 30, 2021
@RobinMalfait RobinMalfait changed the title Handle proper fallbacks in config [WIP] Handle proper fallbacks in config Sep 30, 2021
Currently we had to manually add them in the `setupTrackingContext`,
`setupWatchingContext` and the `cli`.

This was a bit cumbersome, because the `safelist` function (to resolve
regex patterns) was implemented on the context. This means that we had
to do something like this:

```js
let changedContent = []
let context = createContext(config, changedContent)
for (let content of context.safelist()) {
  changedContent.push(content)
}
```

This just feels wrong in general, so now it is handled internally for
you which means that we can't mess it up anymore in those 3 spots.
Our transformers and extractors are implemented for `html` for example.
However the `path.extname()` returns `.html`.

This isn't an issue by default, but it could be for with custom
extractors / transformers.
@RobinMalfait RobinMalfait force-pushed the handle-proper-fallbacks-in-config branch 2 times, most recently from 322b3d9 to e16d5d4 Compare October 1, 2021 10:50
@RobinMalfait RobinMalfait changed the title [WIP] Handle proper fallbacks in config Handle proper fallbacks in config Oct 1, 2021
@RobinMalfait RobinMalfait force-pushed the handle-proper-fallbacks-in-config branch from e16d5d4 to e22e46a Compare October 1, 2021 10:53
@RobinMalfait RobinMalfait merged commit d94541c into master Oct 1, 2021
@RobinMalfait RobinMalfait deleted the handle-proper-fallbacks-in-config branch October 1, 2021 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants