mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-13 21:54:38 -04:00
Improve babel example and description of options
This commit is contained in:
parent
d1874c5f59
commit
86a4a50884
@ -3,31 +3,34 @@ title: js.Babel
|
|||||||
description: Compiles the given JavaScript resource with Babel.
|
description: Compiles the given JavaScript resource with Babel.
|
||||||
categories: []
|
categories: []
|
||||||
keywords: []
|
keywords: []
|
||||||
weight: 100
|
|
||||||
action:
|
action:
|
||||||
aliases: [babel,/hugo-pipes/babel/]
|
aliases: [babel]
|
||||||
related:
|
related:
|
||||||
|
- functions/js/Batch
|
||||||
- functions/js/Build
|
- functions/js/Build
|
||||||
- functions/resources/Fingerprint
|
- functions/resources/Fingerprint
|
||||||
- functions/resources/Minify
|
- functions/resources/Minify
|
||||||
returnType: resource.Resource
|
returnType: resource.Resource
|
||||||
signatures: ['js.Babel [OPTIONS] RESOURCE']
|
signatures: ['js.Babel [OPTIONS] RESOURCE']
|
||||||
|
weight: 30
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
{{< new-in 0.128.0 >}}
|
|
||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ with resources.Get "js/main.js" }}
|
{{ with resources.Get "js/main.js" }}
|
||||||
{{ if hugo.IsDevelopment }}
|
{{ $opts := dict
|
||||||
{{ with . | babel }}
|
"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 }}
|
||||||
<script src="{{ .RelPermalink }}"></script>
|
<script src="{{ .RelPermalink }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
|
||||||
{{ $opts := dict "minified" true }}
|
|
||||||
{{ with . | babel $opts | fingerprint }}
|
|
||||||
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
```
|
```
|
||||||
@ -72,20 +75,32 @@ module.exports = {
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
config
|
###### compact
|
||||||
: (`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).
|
|
||||||
|
|
||||||
minified
|
(`bool`) Whether to remove optional newlines and whitespace. Enabled when `minified` is `true`. Default is `false`
|
||||||
: (`bool`) Save as many bytes as possible when printing
|
|
||||||
|
|
||||||
noComments
|
###### config
|
||||||
: (`bool`) Write comments to generated output (true by default)
|
|
||||||
|
|
||||||
compact
|
(`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).
|
||||||
: (`bool`) Do not include superfluous whitespace characters and line terminators. Defaults to `auto` if not set.
|
|
||||||
|
|
||||||
verbose
|
###### minified
|
||||||
: (`bool`) Log everything
|
|
||||||
|
|
||||||
sourceMap
|
(`bool`) Whether to minify the compiled code. Enables the `compact` option. Default is `false`.
|
||||||
: (`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.
|
|
||||||
|
###### 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
|
title: js.Batch
|
||||||
description: Build JavaScript bundle groups with global code splitting and flexible hooks/runners setup.
|
description: Build JavaScript bundle groups with global code splitting and flexible hooks/runners setup.
|
||||||
weight: 50
|
|
||||||
categories: []
|
categories: []
|
||||||
keywords: []
|
keywords: []
|
||||||
action:
|
action:
|
||||||
@ -13,6 +12,7 @@ action:
|
|||||||
- functions/resources/Minify
|
- functions/resources/Minify
|
||||||
returnType: js.Batcher
|
returnType: js.Batcher
|
||||||
signatures: ['js.Batch [ID]']
|
signatures: ['js.Batch [ID]']
|
||||||
|
weight: 20
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
---
|
---
|
||||||
title: js.Build
|
title: js.Build
|
||||||
description: Bundles, transpiles, tree shakes, and minifies JavaScript resources.
|
description: Bundles, transpiles, tree shakes, and minifies JavaScript resources.
|
||||||
weight: 30
|
|
||||||
categories: []
|
categories: []
|
||||||
keywords: []
|
keywords: []
|
||||||
action:
|
action:
|
||||||
aliases: []
|
aliases: []
|
||||||
related:
|
related:
|
||||||
|
- functions/js/Batch
|
||||||
- functions/js/Babel
|
- functions/js/Babel
|
||||||
- functions/resources/Fingerprint
|
- functions/resources/Fingerprint
|
||||||
- functions/resources/Minify
|
- functions/resources/Minify
|
||||||
returnType: resource.Resource
|
returnType: resource.Resource
|
||||||
signatures: ['js.Build [OPTIONS] RESOURCE']
|
signatures: ['js.Build [OPTIONS] RESOURCE']
|
||||||
|
weight: 10
|
||||||
toc: true
|
toc: true
|
||||||
---
|
---
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ categories: []
|
|||||||
keywords: []
|
keywords: []
|
||||||
action:
|
action:
|
||||||
related:
|
related:
|
||||||
|
- functions/js/Batch
|
||||||
- functions/js/Build
|
- functions/js/Build
|
||||||
- functions/resources/Fingerprint
|
- functions/resources/Fingerprint
|
||||||
- functions/resources/Minify
|
- functions/resources/Minify
|
||||||
@ -22,15 +23,19 @@ Use [`js.Babel`] instead.
|
|||||||
|
|
||||||
```go-html-template
|
```go-html-template
|
||||||
{{ with resources.Get "js/main.js" }}
|
{{ with resources.Get "js/main.js" }}
|
||||||
{{ if hugo.IsDevelopment }}
|
{{ $opts := dict
|
||||||
{{ with . | babel }}
|
"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 }}
|
||||||
<script src="{{ .RelPermalink }}"></script>
|
<script src="{{ .RelPermalink }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ else }}
|
|
||||||
{{ $opts := dict "minified" true }}
|
|
||||||
{{ with . | babel $opts | fingerprint }}
|
|
||||||
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
```
|
```
|
||||||
@ -75,20 +80,32 @@ module.exports = {
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
config
|
###### compact
|
||||||
: (`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).
|
|
||||||
|
|
||||||
minified
|
(`bool`) Whether to remove optional newlines and whitespace. Enabled when `minified` is `true`. Default is `false`
|
||||||
: (`bool`) Save as many bytes as possible when printing
|
|
||||||
|
|
||||||
noComments
|
###### config
|
||||||
: (`bool`) Write comments to generated output (true by default)
|
|
||||||
|
|
||||||
compact
|
(`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).
|
||||||
: (`bool`) Do not include superfluous whitespace characters and line terminators. Defaults to `auto` if not set.
|
|
||||||
|
|
||||||
verbose
|
###### minified
|
||||||
: (`bool`) Log everything
|
|
||||||
|
|
||||||
sourceMap
|
(`bool`) Whether to minify the compiled code. Enables the `compact` option. Default is `false`.
|
||||||
: (`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.
|
|
||||||
|
###### 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