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

fix: tailwindcss content sources #783

Merged
merged 2 commits into from Oct 7, 2022
Merged

Conversation

cossssmin
Copy link
Member

@cossssmin cossssmin commented Oct 7, 2022

This PR fixes a performance issue where we always included ./src/**/*.* in the content array when compiling Tailwind CSS.

This not only included a very broad pattern, but started significantly slowing builds down as more files were added to the src folder. It was especially noticeable when image (or other large binary) files were added to ./src/images.

Now, the default content sources are:

content: {
  files: [
    './src/components/**.html',
    './src/layouts/**.html',
    {raw: html, extension: 'html'}
  ]
}

... where html is the HTML string currently being processed.

If you add your own content key to tailwind.config.js, this will be overwritten to:

{
  files: [
    ...config.content,
    {raw: html, extension: 'html'}
  ]
}

... meaning that you need to make sure to also add any paths to Components or Layouts:

// tailwind.config.js

module.exports = {
  content: [
    './src/components/**.html',
    './src/layouts/**.html',
    // other content sources...
  ],
}

@cossssmin cossssmin merged commit 3884725 into master Oct 7, 2022
@cossssmin cossssmin deleted the fix-tailwindcss-content branch October 7, 2022 16:38
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.

None yet

1 participant