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
check_darwin.go
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
gen.go
genautocomplete.go
genchromastyles.go
gendoc.go
gendocshelper.go
genman.go
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
import_jekyll.go
import_jekyll_test.go
limit_darwin.go
limit_others.go
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
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
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