mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Merge commit '28bd06265e88454b061810578919d891909a83ad'
This commit is contained in:
commit
673e622fa9
10 changed files with 114 additions and 42 deletions
|
@ -9,9 +9,9 @@ keywords: []
|
|||
menu:
|
||||
docs:
|
||||
parent: "pipes"
|
||||
weight: 49
|
||||
weight: 49
|
||||
sections_weight: 49
|
||||
weight: 48
|
||||
weight: 48
|
||||
sections_weight: 48
|
||||
draft: false
|
||||
---
|
||||
|
||||
|
|
63
docs/content/en/hugo-pipes/js.md
Normal file
63
docs/content/en/hugo-pipes/js.md
Normal file
|
@ -0,0 +1,63 @@
|
|||
---
|
||||
title: JavaScript Building
|
||||
description: Hugo Pipes can process JavaScript files with [ESBuild](https://github.com/evanw/esbuild).
|
||||
date: 2020-07-20
|
||||
publishdate: 2020-07-20
|
||||
lastmod: 2020-07-20
|
||||
categories: [asset management]
|
||||
keywords: []
|
||||
menu:
|
||||
docs:
|
||||
parent: "pipes"
|
||||
weight: 45
|
||||
weight: 45
|
||||
sections_weight: 45
|
||||
draft: false
|
||||
---
|
||||
|
||||
Any JavaScript resource file can be transpiled and "tree shaken" using `js.Build` which takes for argument either a string for the filepath or a dict of options listed below.
|
||||
|
||||
### Options
|
||||
|
||||
targetPath [string]
|
||||
: If not set, the source path will be used as the base target path.
|
||||
Note that the target path's extension may change if the target MIME type is different, e.g. when the source is TypeScript.
|
||||
|
||||
minify [bool]
|
||||
: Let `js.Build` handle the minification.
|
||||
|
||||
target [string]
|
||||
: The language target.
|
||||
One of: `es2015`, `es2016`, `es2017`, `es2018`, `es2019`, `es2020` or `esnext`.
|
||||
Default is `esnext`.
|
||||
|
||||
externals [slice]
|
||||
: External dependencies. If a dependency should not be included in the bundle (Ex. library loaded from a CDN.), it should be listed here.
|
||||
|
||||
```go-html-template
|
||||
{{ $externals := slice "react" "react-dom" }}
|
||||
```
|
||||
|
||||
defines [map]
|
||||
: Allow to define a set of string replacement to be performed when building. Should be a map where each key is to be replaced by its value.
|
||||
|
||||
```go-html-template
|
||||
{{ $defines := dict "process.env.NODE_ENV" `"development"` }}
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```go-html-template
|
||||
{{ $built := resources.Get "js/index.js" | js.Build "main.js" }}
|
||||
```
|
||||
|
||||
Or with options:
|
||||
|
||||
```go-html-template
|
||||
{{ $externals := slice "react" "react-dom" }}
|
||||
{{ $defines := dict "process.env.NODE_ENV" `"development"` }}
|
||||
|
||||
{{ $opts := dict "targetPath" "main.js" "externals" $externals "defines" $defines }}
|
||||
{{ $built := resources.Get "scripts/main.js" | js.Build $opts }}
|
||||
<script type="text/javascript" src="{{ $built.RelPermalink }}" defer></script>
|
||||
```
|
BIN
docs/content/en/news/0.74.0-relnotes/featured.png
Normal file
BIN
docs/content/en/news/0.74.0-relnotes/featured.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 55 KiB |
|
@ -1,25 +1,32 @@
|
|||
|
||||
---
|
||||
date: 2020-07-13
|
||||
title: "0.74.0"
|
||||
description: "0.74.0"
|
||||
title: "Native JS Bundler, Open API Support, Inline Partials"
|
||||
description: "Hugo 0.74.0 brings blazingly fast native JavaScript bundling, with minification, tree shaking, scope hoisting for ES6 modules, and transpilation of JSX and newer JS syntax down to ES6. And more."
|
||||
categories: ["Releases"]
|
||||
---
|
||||
|
||||
**Note:** The documentation site isn't updated with all of the main new things below. We will get to it soon.
|
||||
**Note:** The documentation site isn't updated with all of the main new things below. We will get to it soon. See https://github.com/gohugoio/hugoDocs/issues/1171
|
||||
|
||||
This release comes with native JavaScript bundling (and minifier), with [import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) support (from `node_modules` etc.), tree shaking, scope hoisting for ES6 modules, transpilation of JSX and newer JS syntax down to ES6, JavaScript/JSX and TypeScript/TSX support. And it's _very fast_. [Benchmarks](https://github.com/evanw/esbuild#benchmarks) rates it at least 100x faster than the other JavaScript bundlers included. This new feature is backed by the very impressive [ESBuild](https://github.com/evanw/esbuild) project by [@evanw](https://github.com/evanw). Many thanks to [@remko](https://github.com/remko) for the integration work.
|
||||
This release comes with native JavaScript bundling (and minifier), with [import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import) support (from `node_modules` etc.), tree shaking, scope hoisting for ES6 modules, transpilation of JSX and newer JS syntax down to ES6, JavaScript/JSX and TypeScript/TSX support. And it's _very fast_. [Benchmarks](https://github.com/evanw/esbuild#benchmarks) rates it **at least 100x faster** than the other JavaScript bundlers included. This new feature is backed by the very impressive [ESBuild](https://github.com/evanw/esbuild) project by [@evanw](https://github.com/evanw). Many thanks to [@remko](https://github.com/remko) for the integration work.
|
||||
|
||||
A very simple example building a TypeScript file:
|
||||
|
||||
```go-html-template
|
||||
{{ $js := resources.Get "js/main.ts" | js.Build }}
|
||||
```
|
||||
This release also comes with Open API 3-support. This makes it much easier to create "Swagger styled" API-documentation. The below will unmarshal your YAML file into [this object graph](https://godoc.org/github.com/getkin/kin-openapi/openapi3#Swagger):
|
||||
|
||||
````go-html-template
|
||||
```go-html-template
|
||||
{{ $api := resources.Get "api/openapi.yaml" | openapi3.Unmarshal }}
|
||||
```
|
||||
|
||||
Hugo's Asciidoc integration has also gotten a face lift. A big shoutout to [@muenchhausen](https://github.com/muenchhausen) and [@bwklein](https://github.com/bwklein) for their work on this.
|
||||
|
||||
And finally, [partials](https://gohugo.io/templates/partials/#inline-partials) can now be defined inline -- and that is way more useful than it sounds.
|
||||
|
||||
This release represents **23 contributions by 9 contributors** to the main Hugo code base.[@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@niklasfasching](https://github.com/niklasfasching), [@bwklein](https://github.com/bwklein, and [@muenchhausen](https://github.com/muenchhausen) for their ongoing contributions.
|
||||
|
||||
This release represents **23 contributions by 9 contributors** to the main Hugo code base. [@bep](https://github.com/bep) leads the Hugo development with a significant amount of contributions, but also a big shoutout to [@niklasfasching](https://github.com/niklasfasching), [@bwklein](https://github.com/bwklein), and [@muenchhausen](https://github.com/muenchhausen) for their ongoing contributions.
|
||||
|
||||
And a big thanks to [@digitalcraftsman](https://github.com/digitalcraftsman) for his relentless work on keeping the themes site in pristine condition and to [@davidsneighbour](https://github.com/davidsneighbour), [@coliff](https://github.com/coliff) and [@kaushalmodi](https://github.com/kaushalmodi) for all the great work on the documentation site.
|
||||
|
||||
|
@ -76,6 +83,3 @@ Hugo now has:
|
|||
* Fix server reload when non-HTML shortcode changes [42e150fb](https://github.com/gohugoio/hugo/commit/42e150fbfac736bd49bc7e50cb8cdf9f81386f59) [@bep](https://github.com/bep) [#7448](https://github.com/gohugoio/hugo/issues/7448)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
---
|
||||
date: 2020-07-13
|
||||
title: "Hugo 0.74.1: A couple of Bug Fixes"
|
||||
description: "This version fixes a couple of bugs introduced in 0.74.0."
|
||||
description: "This version fixes one issue introduced in 0.74.0."
|
||||
categories: ["Releases"]
|
||||
images:
|
||||
- images/blog/hugo-bug-poster.png
|
||||
|
|
|
@ -11,9 +11,14 @@ images:
|
|||
|
||||
|
||||
|
||||
This is a bug-fix release with one important fix.
|
||||
|
||||
* Add .Defines to js.Build options [35011bcb](https://github.com/gohugoio/hugo/commit/35011bcb26b6fcfcbd77dc05aa8246ca45b2c2ba) [@bep](https://github.com/bep) [#7489](https://github.com/gohugoio/hugo/issues/7489)
|
||||
Add .Defines to js.Build options [35011bcb](https://github.com/gohugoio/hugo/commit/35011bcb26b6fcfcbd77dc05aa8246ca45b2c2ba) [@bep](https://github.com/bep) [#7489](https://github.com/gohugoio/hugo/issues/7489)
|
||||
|
||||
This is needed to import `react` as a library, e.g.:
|
||||
|
||||
```
|
||||
{{ $jsx := resources.Get "index.jsx" }}
|
||||
{{ $options := dict "defines" (dict "process.env.NODE_ENV" "\"development\"") }}
|
||||
{{ $js := $jsx | js.Build $options }}
|
||||
```
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ publish = "public"
|
|||
command = "hugo --gc --minify"
|
||||
|
||||
[context.production.environment]
|
||||
HUGO_VERSION = "0.73.0"
|
||||
HUGO_VERSION = "0.74.2"
|
||||
HUGO_ENV = "production"
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
||||
|
@ -11,20 +11,20 @@ HUGO_ENABLEGITINFO = "true"
|
|||
command = "hugo --gc --minify --enableGitInfo"
|
||||
|
||||
[context.split1.environment]
|
||||
HUGO_VERSION = "0.73.0"
|
||||
HUGO_VERSION = "0.74.2"
|
||||
HUGO_ENV = "production"
|
||||
|
||||
[context.deploy-preview]
|
||||
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
|
||||
|
||||
[context.deploy-preview.environment]
|
||||
HUGO_VERSION = "0.73.0"
|
||||
HUGO_VERSION = "0.74.2"
|
||||
|
||||
[context.branch-deploy]
|
||||
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
|
||||
|
||||
[context.branch-deploy.environment]
|
||||
HUGO_VERSION = "0.73.0"
|
||||
HUGO_VERSION = "0.74.2"
|
||||
|
||||
[context.next.environment]
|
||||
HUGO_ENABLEGITINFO = "true"
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
Loading…
Reference in a new issue