Skip to content

Webpack Loader for Nunjucks that returns raw html. Also works with Webpack watching system.

License

Notifications You must be signed in to change notification settings

sky-foundry/nunjucks-html-loader

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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...

About

Webpack Loader for Nunjucks that returns raw html. Also works with Webpack watching system.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%