mirror of
https://github.com/gohugoio/hugo.git
synced 2025-09-01 22:42:45 +02:00
Merge commit 'a6e635ca7d905d9ec3ffd708db2694f680b03aae'
This commit is contained in:
@@ -11,12 +11,12 @@ weight: 70
|
||||
function:
|
||||
aliases: [babel]
|
||||
returnType: resource.Resource
|
||||
signatures: ['resources.Babel [OPTIONS] RESOURCE']
|
||||
signatures: ['js.Babel [OPTIONS] RESOURCE']
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
Any JavaScript resource file can be transpiled to another JavaScript version using `resources.Babel` which takes for argument the resource object and an optional dict of options listed below. Babel uses the [babel cli](https://babeljs.io/docs/en/babel-cli).
|
||||
Any JavaScript resource file can be transpiled to another JavaScript version using `js.Babel` which takes for argument the resource object and an optional dict of options listed below. Babel uses the [babel cli](https://babeljs.io/docs/en/babel-cli).
|
||||
|
||||
{{% note %}}
|
||||
Hugo Pipe's Babel requires the `@babel/cli` and `@babel/core` JavaScript packages to be installed in the project or globally (`npm install -g @babel/cli @babel/core`) along with any Babel plugin(s) or preset(s) used (e.g., `npm install @babel/preset-env --save-dev`).
|
||||
|
@@ -62,7 +62,7 @@ Hugo publishes assets to the `publishDir` (typically `public`) when you invoke `
|
||||
For improved readability, the Hugo Pipes examples of this documentation will be written using [Go Pipes](/templates/introduction/#pipes):
|
||||
|
||||
```go-html-template
|
||||
{{ $style := resources.Get "sass/main.scss" | resources.ToCSS | resources.Minify | resources.Fingerprint }}
|
||||
{{ $style := resources.Get "sass/main.scss" | css.Sass | resources.Minify | resources.Fingerprint }}
|
||||
<link rel="stylesheet" href="{{ $style.Permalink }}">
|
||||
```
|
||||
|
||||
|
@@ -12,7 +12,7 @@ toc: true
|
||||
action:
|
||||
aliases: [postCSS]
|
||||
returnType: resource.Resource
|
||||
signatures: ['resources.PostCSS [OPTIONS] RESOURCE']
|
||||
signatures: ['css.PostCSS [OPTIONS] RESOURCE']
|
||||
---
|
||||
|
||||
## Setup
|
||||
@@ -50,7 +50,7 @@ Step 4
|
||||
: Place your CSS file within the `assets` directory.
|
||||
|
||||
Step 5
|
||||
: Capture the CSS file as a resource and pipe it through `resources.PostCSS` (alias `postCSS`):
|
||||
: Capture the CSS file as a resource and pipe it through `css.PostCSS` (alias `postCSS`):
|
||||
|
||||
{{< code file=layouts/partials/css.html >}}
|
||||
{{ with resources.Get "css/main.css" | postCSS }}
|
||||
@@ -68,7 +68,7 @@ If starting with a Sass file within the `assets` directory:
|
||||
|
||||
## Options
|
||||
|
||||
The `resources.PostCSS` method takes an optional map of options.
|
||||
The `css.PostCSS` method takes an optional map of options.
|
||||
|
||||
config
|
||||
: (`string`) The directory that contains the PostCSS configuration file. Default is the root of the project directory.
|
||||
@@ -82,8 +82,8 @@ URL imports (e.g. `@import url('https://fonts.googleapis.com/css?family=Open+San
|
||||
Note that this import routine does not care about the CSS spec, so you can have @import anywhere in the file.
|
||||
Hugo will look for imports relative to the module mount and will respect theme overrides.
|
||||
|
||||
skipInlineImportsNotFound {{< new-in 0.99.0 >}}
|
||||
: (`bool`) Default is `false`. Before Hugo 0.99.0 when `inlineImports` was enabled and we failed to resolve an import, we logged it as a warning. We now fail the build. If you have regular CSS imports in your CSS that you want to preserve, you can either use imports with URL or media queries (Hugo does not try to resolve those) or set `skipInlineImportsNotFound` to true.
|
||||
skipInlineImportsNotFound
|
||||
: (`bool`) Default is `false`. If you have regular CSS imports in your CSS that you want to preserve, you can either use imports with URL or media queries (Hugo does not try to resolve those) or set `skipInlineImportsNotFound` to true.
|
||||
|
||||
{{< code file=layouts/partials/css.html >}}
|
||||
{{ $opts := dict "config" "config-directory" "noMap" true }}
|
||||
|
@@ -27,7 +27,7 @@ There are currently two limitations to this:
|
||||
|
||||
```go-html-template
|
||||
{{ $css := resources.Get "css/main.css" }}
|
||||
{{ $css = $css | resources.PostCSS | minify | fingerprint | resources.PostProcess }}
|
||||
{{ $css = $css | css.PostCSS | minify | fingerprint | resources.PostProcess }}
|
||||
{{ $css.RelPermalink | upper }}
|
||||
```
|
||||
|
||||
@@ -70,7 +70,7 @@ Note that in the example above, the "CSS purge step" will only be applied to the
|
||||
|
||||
```go-html-template
|
||||
{{ $css := resources.Get "css/main.css" }}
|
||||
{{ $css = $css | resources.PostCSS }}
|
||||
{{ $css = $css | css.PostCSS }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ $css = $css | minify | fingerprint | resources.PostProcess }}
|
||||
{{ end }}
|
||||
|
@@ -34,5 +34,5 @@ body{
|
||||
|
||||
```go-html-template
|
||||
{{ $sassTemplate := resources.Get "sass/template.scss" }}
|
||||
{{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | resources.ToCSS }}
|
||||
{{ $style := $sassTemplate | resources.ExecuteAsTemplate "main.scss" . | css.Sass }}
|
||||
```
|
||||
|
@@ -13,7 +13,7 @@ weight: 30
|
||||
action:
|
||||
aliases: [toCSS]
|
||||
returnType: resource.Resource
|
||||
signatures: ['resources.ToCSS [OPTIONS] RESOURCE']
|
||||
signatures: ['css.Sass [OPTIONS] RESOURCE']
|
||||
toc: true
|
||||
aliases: [/hugo-pipes/transform-to-css/]
|
||||
---
|
||||
@@ -73,7 +73,7 @@ includePaths
|
||||
"transpiler" "dartsass"
|
||||
"targetPath" "css/style.css"
|
||||
"vars" site.Params.styles
|
||||
"enableSourceMap" (not hugo.IsProduction)
|
||||
"enableSourceMap" (not hugo.IsProduction)
|
||||
"includePaths" (slice "node_modules/bootstrap/scss")
|
||||
}}
|
||||
{{ with resources.Get "sass/main.scss" | toCSS $opts | minify | fingerprint }}
|
||||
@@ -136,8 +136,8 @@ To install Dart Sass for your builds on GitLab Pages, the `.gitlab-ci.yml` file
|
||||
|
||||
```yaml
|
||||
variables:
|
||||
HUGO_VERSION: 0.126.0
|
||||
DART_SASS_VERSION: 1.77.1
|
||||
HUGO_VERSION: 0.128.0
|
||||
DART_SASS_VERSION: 1.77.5
|
||||
GIT_DEPTH: 0
|
||||
GIT_STRATEGY: clone
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
@@ -170,8 +170,8 @@ To install Dart Sass for your builds on Netlify, the `netlify.toml` file should
|
||||
|
||||
```toml
|
||||
[build.environment]
|
||||
HUGO_VERSION = "0.122.2"
|
||||
DART_SASS_VERSION = "1.77.1"
|
||||
HUGO_VERSION = "0.128.0"
|
||||
DART_SASS_VERSION = "1.77.5"
|
||||
TZ = "America/Los_Angeles"
|
||||
|
||||
[build]
|
||||
@@ -187,7 +187,7 @@ command = """\
|
||||
|
||||
### Example
|
||||
|
||||
To transpile with Dart Sass, set `transpiler` to `dartsass` in the options map passed to `resources.ToCSS`. For example:
|
||||
To transpile with Dart Sass, set `transpiler` to `dartsass` in the options map passed to `css.Sass`. For example:
|
||||
|
||||
```go-html-template
|
||||
{{ $opts := dict "transpiler" "dartsass" "targetPath" "css/style.css" }}
|
||||
|
Reference in New Issue
Block a user