80dd7b067 theme: Fix border class in render-codeblock template 0d3fde6c9 content: Fix typo 23a4adb29 content: More site => project changes 9243e9f6b content: Rename site configuration to project configuration (phase 2) 330aa2249 content: Miscellaneous edits 25ce893be content: Clarify sort order with PAGE.Rotate b398506dc content: Various dimension improvements c54573d13 content: Use singular form in method section descriptions d9a95fe54 content: Improve description of PAGE.Rotate 154f30600 content: Fix link c71bd2776 content: Address Markdown linting error 72c88e68e content: Improve pages related to content dimensions b85afa645 content: Fix formatting 7aaca8947 content: More site-to-project changes 8e1579030 content: Update quick start guide f7ba1fde2 content: Make new-in into a note 8b9d51584 theme: Address TailwindCSS warnings 3a4c2a25c theme: Address Hugo v0.156.0 deprecations 4f1a2bd7b content: Improve glossary entries 21bcd23a6 content: Update glossary entry c72ef1116 content: Update quick start guide c0737ffab content: Add typography plugin to TailwindCSS example 80bcb868e content: Remove Site.AllPages from examples 2b9ba5831 content: Replace Page.Sites and Site.Sites with hugo.Sites 2cdcc2556 content: Remove outdated badges 5a4beb530 content: Replace Site.Data with hugo.Data de4651b5d content: Update glossary entry 2302825a7 content: Add hugo.Data and note other deprecations bac5da4b5 content: Add hugo.Sites and update the other Sites methods 0f7d99153 content: Add Site.IsDefault f888f33bb content: Update glossary entries 65311c2de content: Include the "build" subcommand where appropriate 4991320d2 content: Standard shell language code in info strings b16d9f162 theme: Style todo lists f121450c6 content: Update version references 5a81dd8c2 content: Update CLI documentation f3ae0ce86 content: Rename site configuration to project configuration (phase 1) 9c8327119 content: Miscellaneous edits fbff91e22 Update HUGO_VERSION to 0.156.0 2ec625ae8 content: Restore snap installation instructions fc8c246b8 content: Clarify module initialization git-subtree-dir: docs git-subtree-split: 80dd7b067c31c28b13c51f3ac4636890509a4bb7
3.7 KiB
title, linkTitle, description, categories, keywords, aliases
| title | linkTitle | description | categories | keywords | aliases | |
|---|---|---|---|---|---|---|
| Configure build | Build | Configure global build options. |
|
The build configuration section contains global build-related configuration options.
{{< code-toggle config=build />}}
- buildStats
- See the build stats section below.
- cachebusters
- See the cache busters section below.
- noJSConfigInAssets
- (
bool) Whether to disable writing ajsconfig.jsonin yourassetsdirectory with mapping of imports from running js.Build. This file is intended to help with intellisense/navigation inside code editors such as VS Code. Note that if you do not usejs.Build, no file will be written. - useResourceCacheWhen
- (
string) When to use the resource file cache, one ofnever,fallback, oralways. Applicable when transpiling Sass to CSS. Default isfallback.
Cache busters
The build.cachebusters configuration option was added to support development using Tailwind 3.x's JIT compiler where a build configuration may look like this:
{{< code-toggle file=hugo >}} [build] [build.buildStats] enable = true build.cachebusters source = "assets/watching/hugo_stats\.json" target = "styles\.css" build.cachebusters source = "(postcss|tailwind)\.config\.js" target = "css" build.cachebusters source = "assets/.\.(js|ts|jsx|tsx)" target = "js" build.cachebusters source = "assets/.\.(.*)$" target = "$1" {{< /code-toggle >}}
When buildStats is enabled, Hugo writes a hugo_stats.json file on each build with HTML classes etc. that's used in the rendered output. Changes to this file will trigger a rebuild of the styles.css file. You also need to add hugo_stats.json to Hugo's server watcher. See Hugo Starter Tailwind Basic for a running example.
- source
- (
string) A regular expression matching file(s) relative to one of the virtual component directories in Hugo, typicallyassets/.... - target
- (
string) A regular expression matching the keys in the resource cache that should be expired whensourcechanges. You can use the matching regexp groups fromsourcein the expression, e.g.$1.
Build stats
{{< code-toggle config=build.buildStats />}}
- enable
- (
bool) Whether to create ahugo_stats.jsonfile in the root of your project. This file contains arrays of theclassattributes,idattributes, and tags of every HTML element within your published site. Use this file as data source when removing unused CSS from your site. This process is also known as pruning, purging, or tree shaking. Default isfalse.
- disableIDs
- (
bool) Whether to excludeidattributes. Default isfalse. - disableTags
- (
bool) Whether to exclude element tags. Default isfalse. - disableClasses
- (
bool) Whether to excludeclassattributes. Default isfalse.
Note
Given that CSS purging is typically limited to production builds, place the
buildStatsobject belowconfig/production.Built for speed, there may be "false positive" detections (e.g., HTML elements that are not HTML elements) while parsing the published site. These "false positives" are infrequent and inconsequential.
Due to the nature of partial server builds, new HTML entities are added while the server is running, but old values will not be removed until you restart the server or run hugo build.