mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-13 15:49:17 -04:00
Improve babel example and description of options
This commit is contained in:
parent
d1874c5f59
commit
86a4a50884
@ -3,30 +3,33 @@ title: js.Babel
|
||||
description: Compiles the given JavaScript resource with Babel.
|
||||
categories: []
|
||||
keywords: []
|
||||
weight: 100
|
||||
action:
|
||||
aliases: [babel,/hugo-pipes/babel/]
|
||||
aliases: [babel]
|
||||
related:
|
||||
- functions/js/Batch
|
||||
- functions/js/Build
|
||||
- functions/resources/Fingerprint
|
||||
- functions/resources/Minify
|
||||
returnType: resource.Resource
|
||||
signatures: ['js.Babel [OPTIONS] RESOURCE']
|
||||
weight: 30
|
||||
toc: true
|
||||
---
|
||||
|
||||
{{< new-in 0.128.0 >}}
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "js/main.js" }}
|
||||
{{ if hugo.IsDevelopment }}
|
||||
{{ with . | babel }}
|
||||
<script src="{{ .RelPermalink }}"></script>
|
||||
{{ $opts := dict
|
||||
"minified" hugo.IsProduction
|
||||
"noComments" hugo.IsProduction
|
||||
"sourceMap" (cond hugo.IsProduction "none" "external")
|
||||
}}
|
||||
{{ with . | js.Babel $opts }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ with . | fingerprint }}
|
||||
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $opts := dict "minified" true }}
|
||||
{{ with . | babel $opts | fingerprint }}
|
||||
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
<script src="{{ .RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@ -72,20 +75,32 @@ module.exports = {
|
||||
|
||||
## Options
|
||||
|
||||
config
|
||||
: (`string`) Path to the Babel configuration file. Hugo will, by default, look for a `babel.config.js` in your project. More information on these configuration files can be found here: [babel configuration](https://babeljs.io/docs/en/configuration).
|
||||
###### compact
|
||||
|
||||
minified
|
||||
: (`bool`) Save as many bytes as possible when printing
|
||||
(`bool`) Whether to remove optional newlines and whitespace. Enabled when `minified` is `true`. Default is `false`
|
||||
|
||||
noComments
|
||||
: (`bool`) Write comments to generated output (true by default)
|
||||
###### config
|
||||
|
||||
compact
|
||||
: (`bool`) Do not include superfluous whitespace characters and line terminators. Defaults to `auto` if not set.
|
||||
(`string`) Path to the Babel configuration file. Hugo will, by default, look for a `babel.config.js` file in the root of your project. See [details](https://babeljs.io/docs/en/configuration).
|
||||
|
||||
verbose
|
||||
: (`bool`) Log everything
|
||||
###### minified
|
||||
|
||||
sourceMap
|
||||
: (`string`) Output `inline` or `external` sourcemap from the babel compile. External sourcemaps will be written to the target with the output file name + ".map". Input sourcemaps can be read from js.Build and node modules and combined into the output sourcemaps.
|
||||
(`bool`) Whether to minify the compiled code. Enables the `compact` option. Default is `false`.
|
||||
|
||||
###### noBabelrc
|
||||
|
||||
(`string`) Whether to ignore `.babelrc` and `.babelignore` files. Default is `false`.
|
||||
|
||||
###### noComments
|
||||
|
||||
(`bool`) Whether to remove comments. Default is `false`.
|
||||
|
||||
###### sourceMap
|
||||
|
||||
(`string`) Whether to generate source maps, one of `external`, `inline`, or `none`. Default is `none`.
|
||||
|
||||
<!-- In the above, technically "none" is not one of the enumerated values, but it has the same effect and is easier to document than an empty string. -->
|
||||
|
||||
###### verbose
|
||||
|
||||
(`bool`) Whether to enable verbose logging. Default is `fasle`
|
||||
|
@ -1,7 +1,6 @@
|
||||
---
|
||||
title: js.Batch
|
||||
description: Build JavaScript bundle groups with global code splitting and flexible hooks/runners setup.
|
||||
weight: 50
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
@ -13,6 +12,7 @@ action:
|
||||
- functions/resources/Minify
|
||||
returnType: js.Batcher
|
||||
signatures: ['js.Batch [ID]']
|
||||
weight: 20
|
||||
toc: true
|
||||
---
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
---
|
||||
title: js.Build
|
||||
description: Bundles, transpiles, tree shakes, and minifies JavaScript resources.
|
||||
weight: 30
|
||||
categories: []
|
||||
keywords: []
|
||||
action:
|
||||
aliases: []
|
||||
related:
|
||||
- functions/js/Batch
|
||||
- functions/js/Babel
|
||||
- functions/resources/Fingerprint
|
||||
- functions/resources/Minify
|
||||
returnType: resource.Resource
|
||||
signatures: ['js.Build [OPTIONS] RESOURCE']
|
||||
weight: 10
|
||||
toc: true
|
||||
---
|
||||
|
||||
|
@ -5,6 +5,7 @@ categories: []
|
||||
keywords: []
|
||||
action:
|
||||
related:
|
||||
- functions/js/Batch
|
||||
- functions/js/Build
|
||||
- functions/resources/Fingerprint
|
||||
- functions/resources/Minify
|
||||
@ -22,14 +23,18 @@ Use [`js.Babel`] instead.
|
||||
|
||||
```go-html-template
|
||||
{{ with resources.Get "js/main.js" }}
|
||||
{{ if hugo.IsDevelopment }}
|
||||
{{ with . | babel }}
|
||||
<script src="{{ .RelPermalink }}"></script>
|
||||
{{ $opts := dict
|
||||
"minified" hugo.IsProduction
|
||||
"noComments" hugo.IsProduction
|
||||
"sourceMap" (cond hugo.IsProduction "none" "external")
|
||||
}}
|
||||
{{ with . | js.Babel $opts }}
|
||||
{{ if hugo.IsProduction }}
|
||||
{{ with . | fingerprint }}
|
||||
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $opts := dict "minified" true }}
|
||||
{{ with . | babel $opts | fingerprint }}
|
||||
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
||||
<script src="{{ .RelPermalink }}"></script>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
@ -75,20 +80,32 @@ module.exports = {
|
||||
|
||||
## Options
|
||||
|
||||
config
|
||||
: (`string`) Path to the Babel configuration file. Hugo will, by default, look for a `babel.config.js` in your project. More information on these configuration files can be found here: [babel configuration](https://babeljs.io/docs/en/configuration).
|
||||
###### compact
|
||||
|
||||
minified
|
||||
: (`bool`) Save as many bytes as possible when printing
|
||||
(`bool`) Whether to remove optional newlines and whitespace. Enabled when `minified` is `true`. Default is `false`
|
||||
|
||||
noComments
|
||||
: (`bool`) Write comments to generated output (true by default)
|
||||
###### config
|
||||
|
||||
compact
|
||||
: (`bool`) Do not include superfluous whitespace characters and line terminators. Defaults to `auto` if not set.
|
||||
(`string`) Path to the Babel configuration file. Hugo will, by default, look for a `babel.config.js` file in the root of your project. See [details](https://babeljs.io/docs/en/configuration).
|
||||
|
||||
verbose
|
||||
: (`bool`) Log everything
|
||||
###### minified
|
||||
|
||||
sourceMap
|
||||
: (`string`) Output `inline` or `external` sourcemap from the babel compile. External sourcemaps will be written to the target with the output file name + ".map". Input sourcemaps can be read from js.Build and node modules and combined into the output sourcemaps.
|
||||
(`bool`) Whether to minify the compiled code. Enables the `compact` option. Default is `false`.
|
||||
|
||||
###### noBabelrc
|
||||
|
||||
(`string`) Whether to ignore `.babelrc` and `.babelignore` files. Default is `false`.
|
||||
|
||||
###### noComments
|
||||
|
||||
(`bool`) Whether to remove comments. Default is `false`.
|
||||
|
||||
###### sourceMap
|
||||
|
||||
(`string`) Whether to generate source maps, one of `external`, `inline`, or `none`. Default is `none`.
|
||||
|
||||
<!-- In the above, technically "none" is not one of the enumerated values, but it has the same effect and is easier to document than an empty string. -->
|
||||
|
||||
###### verbose
|
||||
|
||||
(`bool`) Whether to enable verbose logging. Default is `fasle`
|
||||
|
Loading…
x
Reference in New Issue
Block a user