hugo/commands
Bjørn Erik Pedersen dea71670c0
Add Hugo Piper with SCSS support and much more
Before this commit, you would have to use page bundles to do image processing etc. in Hugo.

This commit adds

* A new `/assets` top-level project or theme dir (configurable via `assetDir`)
* A new template func, `resources.Get` which can be used to "get a resource" that can be further processed.

This means that you can now do this in your templates (or shortcodes):

```bash
{{ $sunset := (resources.Get "images/sunset.jpg").Fill "300x200" }}
```

This also adds a new `extended` build tag that enables powerful SCSS/SASS support with source maps. To compile this from source, you will also need a C compiler installed:

```
HUGO_BUILD_TAGS=extended mage install
```

Note that you can use output of the SCSS processing later in a non-SCSSS-enabled Hugo.

The `SCSS` processor is a _Resource transformation step_ and it can be chained with the many others in a pipeline:

```bash
{{ $css := resources.Get "styles.scss" | resources.ToCSS | resources.PostCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

The transformation funcs above have aliases, so it can be shortened to:

```bash
{{ $css := resources.Get "styles.scss" | toCSS | postCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

A quick tip would be to avoid the fingerprinting part, and possibly also the not-superfast `postCSS` when you're doing development, as it allows Hugo to be smarter about the rebuilding.

Documentation will follow, but have a look at the demo repo in https://github.com/bep/hugo-sass-test

New functions to create `Resource` objects:

* `resources.Get` (see above)
* `resources.FromString`: Create a Resource from a string.

New `Resource` transformation funcs:

* `resources.ToCSS`: Compile `SCSS` or `SASS` into `CSS`.
* `resources.PostCSS`: Process your CSS with PostCSS. Config file support (project or theme or passed as an option).
* `resources.Minify`: Currently supports `css`, `js`, `json`, `html`, `svg`, `xml`.
* `resources.Fingerprint`: Creates a fingerprinted version of the given Resource with Subresource Integrity..
* `resources.Concat`: Concatenates a list of Resource objects. Think of this as a poor man's bundler.
* `resources.ExecuteAsTemplate`: Parses and executes the given Resource and data context (e.g. .Site) as a Go template.

Fixes #4381
Fixes #4903
Fixes #4858
2018-07-06 11:46:12 +02:00
..
benchmark.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
check.go commands: Make the limit command work again 2018-04-11 09:50:19 +02:00
check_darwin.go commands: Make the limit command work again 2018-04-11 09:50:19 +02:00
commandeer.go Add Hugo Piper with SCSS support and much more 2018-07-06 11:46:12 +02:00
commands.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
commands_test.go commands: Do not fail server build when /static is missing 2018-06-13 08:48:20 +02:00
config.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
convert.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
env.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
gen.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
genautocomplete.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
genchromastyles.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
gendoc.go commands: Add basic server test 2018-04-11 09:51:07 +02:00
gendocshelper.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
genman.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
helpers.go commands: Avoid ANSI character output on Windows 2018-05-22 17:15:19 +02:00
helpers_others.go commands: Avoid ANSI character output on Windows 2018-05-22 17:15:19 +02:00
helpers_windows.go commands: Avoid ANSI character output on Windows 2018-05-22 17:15:19 +02:00
hugo.go Add Hugo Piper with SCSS support and much more 2018-07-06 11:46:12 +02:00
hugo_windows.go Move cobra.MousetrapHelpText to hugo_windows.go 2015-12-16 21:26:47 -07:00
import_jekyll.go commands: Make the hugo command non-global 2018-04-11 09:50:19 +02:00
import_jekyll_test.go Only set 'url' if permalink in metadata and remove duplicate confirm msg 2018-01-28 11:24:31 +01:00
limit_darwin.go commands: Move the commands related logic to its own file 2018-04-11 09:50:19 +02:00
limit_others.go commands: Make the limit command work again 2018-04-11 09:50:19 +02:00
list.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
new.go commands: Move nextStepsText() to new_site.go 2018-06-11 10:40:22 +02:00
new_content_test.go commands: Remove some TODOs 2018-04-11 10:16:30 +02:00
new_site.go commands: Move nextStepsText() to new_site.go 2018-06-11 10:40:22 +02:00
new_theme.go Create missing head.html partial on new theme generation 2018-06-25 12:06:45 -06:00
release.go commands: Re-add the missing releaser command 2018-04-16 08:23:32 +02:00
release_noop.go commands: Re-add the missing releaser command 2018-04-16 08:23:32 +02:00
server.go commands: Fix broken server-reload on config changes 2018-06-28 12:22:00 +02:00
server_test.go commands: Fix handling of persistent CLI flags 2018-04-13 09:08:49 +02:00
static_syncer.go Add support for theme composition and inheritance 2018-06-10 23:55:20 +02:00
version.go commands: Do not show empty BuildDate in version 2018-05-14 00:08:12 -06:00