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

Use hugo.IsProduction to determine build environment for CSS and JS #651

Merged
merged 1 commit into from
Aug 20, 2021

Conversation

chalin
Copy link
Collaborator

@chalin chalin commented Aug 9, 2021

TL;DR: use hugo.IsProduction to determine build environment (production or development) rather than .Site.IsServer, when deciding which kind of CSS and JS to generate (production-grade or not).


Hugo supports two kinds of build contexts (or "environments" as they are called in the Hugo docs): development and production.

By default, hugo serves a development version of a site, and builds (to disk) a production version. You can change the default for either of these commands by using the -e flag. It can be very useful to build a development version of the site -- e.g., for offline analysis. We can't do this currently due to the use of .Site.IsServer expression in the head-css.html and scripts.html partials. This PR fixes the issue.

/cc @nate-double-u

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 9, 2021
@chalin chalin changed the title Use hugo.IsProduction to determine build environment Use hugo.IsProduction to determine build environment for CSS and JS Aug 9, 2021
@chalin chalin force-pushed the chalin-hugo-production-2021-08-09 branch from fdeaa96 to a4f64cf Compare August 19, 2021 13:42
@LisaFC LisaFC merged commit 3c1b97f into google:master Aug 20, 2021
@chalin chalin deleted the chalin-hugo-production-2021-08-09 branch August 21, 2021 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Indicates the PR's author has signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants