github gohugoio/hugo v0.78.0

latest releases: v0.138.0, v0.137.1, v0.137.0...
4 years ago

This release finally brings full Hugo Modules support to js.Build, curtsy of the new plugin API in the really, really fast ESBuild by @evanw.

Some notes on the improvements in this release:

  • Now js.Build fully supports the virtual union file system in Hugo Modules. Any import inside your JavaScript components will resolve starting from the top component mount inside /assets with a fallback to the traditional "JS way" (node_modules etc.)
  • You can now pass configuration data from the templates to your scripts via a new params option.
  • Hugo now writes a jsconfig.js file inside /assets (you can turn it off) with import mappings to help editors such as VS Code with intellisense/navigation, which is especially useful when there is no common root and the source lives inside some temporary directory.
  • We have also improved the build errors you get from js.Build. In server mode you will get a preview of the failing lines and in the console you will get a link to the location.

Read more about this in the documentation, but a short usage example would look like:

In the template:

{{ $js := resources.Get "js/main.js" | js.Build (dict "params" (dict "api" "https://example.org/api" ) }}

And then in a JavaScript component:

import * as params from '@params';

// Wil resolve to one of `hello.{js,ts,tsx,jsx}` inside `assets/my/module`.
import { hello } from 'my/module/hello';

var api = params.api;

hello();

Changes

Don't miss a new hugo release

NewReleases is sending notifications on new releases.