Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-08-05 12:13:49 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-08-06 20:58:41 +0300
commit789ef8c639e4621abd36da530bcb5942ac9297da (patch)
treef225fc3663affc49805f1d309b77b096d40fc8f6 /commands/hugo.go
parent71931b30b1813b146aaa60f5cdab16c0f9ebebdb (diff)
Add support for minification of final output
Hugo Pipes added minification support for resources fetched via ´resources.Get` and similar. This also adds support for minification of the final output for supported output formats: HTML, XML, SVG, CSS, JavaScript, JSON. To enable, run Hugo with the `--minify` flag: ```bash hugo --minify ``` This commit is also a major spring cleaning of the `transform` package to allow the new minification step fit into that processing chain. Fixes #1251
Diffstat (limited to 'commands/hugo.go')
-rw-r--r--commands/hugo.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/commands/hugo.go b/commands/hugo.go
index 312767499..1381bf210 100644
--- a/commands/hugo.go
+++ b/commands/hugo.go
@@ -209,16 +209,25 @@ func initializeFlags(cmd *cobra.Command, cfg config.Provider) {
"verboseLog",
}
+ // Will set a value even if it is the default.
+ flagKeysForced := []string{
+ "minify",
+ }
+
for _, key := range persFlagKeys {
- setValueFromFlag(cmd.PersistentFlags(), key, cfg, "")
+ setValueFromFlag(cmd.PersistentFlags(), key, cfg, "", false)
}
for _, key := range flagKeys {
- setValueFromFlag(cmd.Flags(), key, cfg, "")
+ setValueFromFlag(cmd.Flags(), key, cfg, "", false)
+ }
+
+ for _, key := range flagKeysForced {
+ setValueFromFlag(cmd.Flags(), key, cfg, "", true)
}
// Set some "config aliases"
- setValueFromFlag(cmd.Flags(), "destination", cfg, "publishDir")
- setValueFromFlag(cmd.Flags(), "i18n-warnings", cfg, "logI18nWarnings")
+ setValueFromFlag(cmd.Flags(), "destination", cfg, "publishDir", false)
+ setValueFromFlag(cmd.Flags(), "i18n-warnings", cfg, "logI18nWarnings", false)
}
@@ -229,9 +238,9 @@ var deprecatedFlags = map[string]bool{
strings.ToLower("canonifyURLs"): true,
}
-func setValueFromFlag(flags *flag.FlagSet, key string, cfg config.Provider, targetKey string) {
+func setValueFromFlag(flags *flag.FlagSet, key string, cfg config.Provider, targetKey string, force bool) {
key = strings.TrimSpace(key)
- if flags.Changed(key) {
+ if (force && flags.Lookup(key) != nil) || flags.Changed(key) {
if _, deprecated := deprecatedFlags[strings.ToLower(key)]; deprecated {
msg := fmt.Sprintf(`Set "%s = true" in your config.toml.
If you need to set this configuration value from the command line, set it via an OS environment variable: "HUGO_%s=true hugo"`, key, strings.ToUpper(key))