@sky-foundry/nunjucks-html-loader

1.2.5 • Public • Published

SkyFoundry Nunjucks (Webpack) HTML Loader

Nunjucks template loader for Webpack to generate static HTML files.

NPM version Github stars

Setup

You should already have a webpack project setup and a webpack config file in your project.

HTML Webpack Plugin

You should first setup html-webpack-plugin with inject: 'body' and template: 'nunjucks-html-loader!./src/pages/index.njk' (your entry nunjucks template).

plugins: [
  new HtmlWebpackPlugin({
    inject: 'body',
    template: 'nunjucks-html-loader!./src/pages/index.njk',
  }),
]

Webpack Copy Plugin

For images and other assets, the CopyPlugin is best suited for this.

The recommended options are:

plugins: [
  // ... (html webpack plugin and others)
  new CopyPlugin([
    {
      from: '**/*.{jpg,png,gif,svg,woff,eot,ttf}',
      context: 'src',
    },
  ]),
]

TO-DO...

Package Sidebar

Install

npm i @sky-foundry/nunjucks-html-loader

Weekly Downloads

1

Version

1.2.5

License

MIT

Unpacked Size

6.33 kB

Total Files

6

Last publish

Collaborators

  • acidic9
  • deckchair-labs
  • matthewattanasio
  • petrinolis