Share via

Use npm commands to automate the build process and to keep track of dependencies.

Hinode uses Node Package Manager to automate the build process and to keep track of dependencies. The package.json file in the repository root defines several commands to simplify local development and testing. The following paragraphs describe the main commands.

Starting a local server

Use the following command from the command prompt to start a local development server. The command removes any previous build artifacts in the public and resources folders. The command invokes the local web server from Hugo, which watches for changes in the key system files and configuration directory. By default the generated site is available at http://localhost:1313/ and is responsive to changes. This alllows for interactive development and testing. When in development mode, the generated assets (such as javascripts and CSS files) are not minified to simplify debugging.

npm run start

Use the following command to mimick the site in production mode. In this setting, generated assets are minified and compliant with the Content Security Policy. Although Hugo’s web server is not meant to be run in a real production environment, it does allow validation of the site in an environment close to production.

npm run start:prod

Generating a web site

Use the following command to generate the static site. The build artifacts are stored in the local public folder. You can deploy these files to your production server.

npm run build

Add the prefix debug to generate a site suitable for debugging. The build artifacts are not minified to simplify review and testing.

npm run build:debug

Validating linting rules

Use the the following command to analyze the source code and to test for any stylistic errors. The lint command validates three types of files in the assets folder and content folder:

  • Javascript (assets/*.js) using eslint.
  • CSS and SASS (assets/scss/**/*.{css,sass,scss,sss,less}) using stylelint.
  • Markdown (*.md and content/**/*.md) using markdownlint-cli2.

The basic configuration of these linting tools is defined in the repository root.

npm run lint

Be sure to adhere to the linting rules before submitting any code changes / Pull Requests to Hinode’s repository.

Upgrading dependencies

Use the following command to test for any available upgrades of used packages. The command runs npx to validate the dependencies and to upgrade the dependency versions in package.json.

npm run upgrade

Be sure to install the upgraded dependencies if needed:

npm install