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

[JIT] Add support for "raw" purge content #4272

Merged
merged 2 commits into from May 7, 2021
Merged

[JIT] Add support for "raw" purge content #4272

merged 2 commits into from May 7, 2021

Conversation

@bradlc
Copy link
Contributor

@bradlc bradlc commented May 7, 2021

Fixes #4094

This PR adds support for specifying raw content as part of the purge config, mimicking the PurgeCSS API:

module.exports = {
  purge: [
    './src/**/*.html',
    { raw: '<div class="bg-red-500"></div>' },
  ],
}

You can also specify an extension which is used to select the appropriate extractor:

module.exports = {
  purge: {
    content: [
      {
        raw: '<div class="bg-red-500"></div>',
        extension: 'html',
      },
    ],
    options: {
      extractors: [
        {
          extractor: (content) => { /* ... */ },
          extensions: ['html'],
        },
      ],
    },
  },
}
@codecov-commenter
Copy link

@codecov-commenter codecov-commenter commented May 7, 2021

Codecov Report

Merging #4272 (a0b2de7) into master (76c670f) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4272      +/-   ##
==========================================
+ Coverage   71.10%   71.15%   +0.04%     
==========================================
  Files         218      218              
  Lines        4703     4711       +8     
  Branches      770      773       +3     
==========================================
+ Hits         3344     3352       +8     
  Misses       1273     1273              
  Partials       86       86              
Impacted Files Coverage Δ
src/jit/lib/expandTailwindAtRules.js 80.88% <100.00%> (+0.57%) ⬆️
src/jit/lib/setupContext.js 72.79% <100.00%> (+0.27%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 76c670f...a0b2de7. Read the comment docs.

@adamwathan
Copy link
Contributor

@adamwathan adamwathan commented May 7, 2021

🤘🏻

@adamwathan adamwathan merged commit 4a374eb into master May 7, 2021
2 checks passed
@adamwathan adamwathan deleted the raw-content branch May 7, 2021
adamwathan added a commit that referenced this issue May 7, 2021
* add support for "raw" purge content

* add support for raw content extensions
@chasegiunta
Copy link

@chasegiunta chasegiunta commented May 19, 2021

@bradlc Would you mind double-checking if the custom extractor (or defaultExtractor) is working correctly / running on watch changes?

I've pulled master (canary) and working with this functionality today, and I'm able to get options.extractors.extractor to work great on initial run, but upon changing the file in watch mode, the extractor is not being used.

@chasegiunta
Copy link

@chasegiunta chasegiunta commented May 19, 2021

Apologies, ignore me, I guess it's a known restriction that custom extractors won't with JIT.

@caseywebdev
Copy link

@caseywebdev caseywebdev commented Jun 1, 2021

@adamwathan this seems to have been reverted in the latest release, any reason why? Was hoping to use it.

@adamwathan
Copy link
Contributor

@adamwathan adamwathan commented Jun 1, 2021

Not reverted just not released yet. You can use our canary build to try it right away if you like!

npm install -D tailwindcss@canary

@caseywebdev
Copy link

@caseywebdev caseywebdev commented Jun 1, 2021

Ah, my bad, I had assumed it would be in today’s release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants