d1a251933theme: Optimize for printingd906488d5theme: Add border to highlighted code blocks within list items9630c38cbtheme: Display short command on commands list7f81dd997content: Regen commands markupa84008e99content: Cleanup primary list page0874b03e9content: Publish QR code examples to the images/qr directoryef1ce3498Restore static/img489a68458content: Restore KeyCDN screen captures7d6e6184btheme: Move search button in navbar to the right on smaller screensb03b96082theme: Misc style adjustmentsecad97821theme: Misc fixescf5e07b0fcontent: Restore example data and imagesc7265041fcontent: Reformat css.TailwindCSS setup steps3226e668ftheme: Make the search button more compact on mobile1f6614ee8content: Update css.TailwindCSS example49a2e7d71theme: Improve search output7e6b81ffamisc: Create issue template826740223theme: Misc search improvements75f32b2f6theme: Remove the search alertfd3de4ac2config: Enable link render hook warnings769e387cdAdjust logic to mark current section for Algoliaba73ce646Adjust markup to make it easier to match in Algolia5accec5f1Misc adjustmentseb5842566Some content adjustmentsbdf97b7b4Add new themeb19d68ee5Remove old themea04e96e55Rewrite the css.TailwindCSS page1c46f1864Update deprecation notesaedcb444cFix typoc3290b876Changes related to release of v0.144.0a0012fccenetlify: Hugo 0.143.19e4d73e87Include sections in quick-reference page collection4591058f5Miscellaneous edits612b8528fglossary: More edits1f0c54e60Fit typo6f14084c1Move glossary to quick reference section2d94905beImprove branch bundle admonition2ea56bef3Fix typos found with codespell71c5fe951Close shortcodee95d06592Document the responseHeaders option for resources.GetRemoteda7c12aaaDeprecate gist shortcodec2d3e2c25netlify: Bump to 0.143.0367d3a7abImprove new-in shortcode1a7413a16Clean up shortcode documentationd847892aaImprove glossary6a7fd42ffUpdate pages describing Store methods and functionsfa7643d1bRevert "Improve link render hook performance"fe4c86ec4Reformat MathJax examplecea44922aUpdate MathJax example to use safe mode0b6d0292cUpdate KaTeX example to use latest versionfd4508645Improve link render hook performance23aeb5bd0Update purgecss examplef7ef83e56Refer each Hugo Pipe page to the corresponding function81b91ef4eRemove related pages from pages for deprecated functions and methods53c7627d5Remove body from deprecated functions and methodsd9cf034c8Consolidate css.ToCSS informationb7ed108f9Improve js.Build example and presentation of options86a4a5088Improve babel example and description of optionsd1874c5f5Consistently use "edition" when referring to standard, extended, etc.92f03a350Revise description of privacy settings152a92d80Update Last.md82a2365bdAdd print-only QR code exampled22cadc25Update mathematics.mdb8160af03Delete page self-reference in page/type.mdce24fe4e0Update param.md51cb92180Improve description of output format template selection78bcf358eUpdate Tailwind CSS npm package version to 4.02ca9da4afInclude winget command to uninstall git-subtree-dir: docs git-subtree-split:d1a2519330
4.3 KiB
title, description, categories, keywords, action, toc
| title | description | categories | keywords | action | toc | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| css.TailwindCSS | Processes the given resource with the Tailwind CSS CLI. |
|
true |
{{< new-in 0.128.0 />}}
Use the css.TailwindCSS function to process your Tailwind CSS files. This function uses the Tailwind CSS CLI to:
- Scan your templates for Tailwind CSS utility class usage.
- Compile those utility classes into standard CSS.
- Generate an optimized CSS output file.
Setup
Step 1
Install the Tailwind CSS CLI v4.0 or later:
npm install --save-dev tailwindcss @tailwindcss/cli
The TailwindCSS CLI is also available as a standalone executable if you want to use it without installing Node.js.
Step 2
Add this to your site configuration:
{{< code-toggle file=hugo copy=true >}} module.mounts source = "assets" target = "assets" module.mounts source = "hugo_stats.json" target = "assets/notwatching/hugo_stats.json" disableWatch = true [build.buildStats] enable = true build.cachebusters source = "assets/notwatching/hugo_stats\.json" target = "css" build.cachebusters source = "(postcss|tailwind)\.config\.js" target = "css" {{< /code-toggle >}}
Step 3
Create a CSS entry file:
{{< code file=assets/css/main.css copy=true >}} @import "tailwindcss"; @source "hugo_stats.json"; {{< /code >}}
Tailwind CSS respects .gitignore files. This means that if hugo_stats.json is listed in your .gitignore file, Tailwind CSS will ignore it. To make hugo_stats.json available to Tailwind CSS you must explicitly source it as shown in the example above.
Step 4
Create a partial template to process the CSS with the Tailwind CSS CLI:
{{< code file=layouts/partials/css.html copy=true >}} {{ with (templates.Defer (dict "key" "global")) }} {{ with resources.Get "css/main.css" }} {{ $opts := dict "minify" hugo.IsProduction "inlineImports" true }} {{ with . | css.TailwindCSS $opts }} {{ if hugo.IsProduction }} {{ with . | fingerprint }} {{ end }} {{ else }} {{ end }} {{ end }} {{ end }} {{ end }} {{< /code >}}
Step 5
Call the partial template from your base template:
{{< code file=layouts/default/baseof.html >}}
<head> ... {{ partialCached "css.html" . }} ... <head> {{< /code >}}Step 6
Optionally create a tailwind.config.js file in the root of your project as shown below. This is necessary if you use the Tailwind CSS IntelliSense
extension for Visual Studio Code.
{{< code file=tailwind.config.js copy=true >}} /* This file is present to satisfy a requirement of the Tailwind CSS IntelliSense extension for Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss
The rest of this file is intentionally empty. */ {{< /code >}}
Options
- minify
- (
bool) Whether to optimize and minify the output. Default isfalse. - optimize
- (
bool) Whether to optimize the output without minifying. Default isfalse. - inlineImports
- (
bool) Whether to enable inlining of@importstatements. Inlining is performed recursively, but currently once only per file. It is not possible to import the same file in different scopes (root, media query, etc.). Note that this import routine does not care about the CSS specification, so you can have@importstatements anywhere in the file. Default isfalse. - skipInlineImportsNotFound
- (
bool) WheninlineImportsis enabled, we fail the build if an import cannot be resolved. Enable this option to allow the build to continue and leave the import statement in place. Note that the inline importer does not process URL location or imports with media queries, so those will be left as-is even without enabling this option. Default isfalse.