Skip to content

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

Notifications You must be signed in to change notification settings

hxfdarling/imt-nunjucks-html-loader

 
 

Repository files navigation

imt-nunjucks-loader

The original 'nunjucks-html-loader' not support relative search path and webpack4 has warning. So, I fork it

Usage

install

npm i -D imt-nunjucks-loader

webpack rules

const configureHtmlLoader = ({ mini, projectDir }) => {
  return {
    test: /\.(html|njk|nunjucks)$/,
    use: [
      {
        loader: resolve('html-loader'),
        options: {
          minimize: mini && env.NODE_ENV === PROD,
        },
      },
      resolve('html-inline-assets-loader'),
      {
        loader: resolve('nunjucks-html-loader'),
        options: {
          // Other super important. This will be the base
          // directory in which webpack is going to find
          // the layout and any other file index.njk is calling.
          // default search path is current resource path
          searchPaths: ['./src', './src/pages', './src/assets'].map(i => path.join(projectDir, i)),
        },
      },
    ],
  };
};

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%