at0g / nunjucks-loader

A webpack loader for nunjucks.
MIT License
79 stars 39 forks source link

opts key for query not working #54

Closed bonesoul closed 6 years ago

bonesoul commented 7 years ago

for webpack2 i have the following config;

      {
        // nunjucks template loader.
        test: /\.html$/, use: [{
          loader: 'nunjucks-loader',
          query: {
            opts: {
              autoescape: true, // escape dangerous characters.
              trimBlocks: true, // automatically remove trailing newlines from a block/tag
              lstripBlocks: true, // automatically remove leading whitespace from a block/tag
              web: {
                useCache: true // will enable cache and templates will never see updates.
              }
            },
            config: __dirname + '/assets/js/common/nunjucks.config.js'
          },
        }]
      },

my nunjucks.config.js;

const moment = require('moment/min/moment-with-locales.min.js');

module.exports = function (env) {
  // add moment to client side nunjucks too.
  env.addGlobal('moment', moment); // eslint-disable-line no-undef

  console.dir(env);
}

and i see on browser that these settings are not applied to env;

opts:
autoescape:true
dev:false
lstripBlocks:false
throwOnUndefined:false
trimBlocks:false

any ideas?

calledT commented 7 years ago

Relative to Introduce getOptions

bonesoul commented 7 years ago

so how can i fix that?