简体   繁体   中英

Grunt nunjucks-2-html

I'm trying to compile my templates via grunt nunjucks-2-html:

this is my simplified grunt file:

module.exports = function(grunt) {

grunt.initConfig({
      nunjucks: {
          options: {
              data: {},
              paths: '/templates/'
          },
          render: {
              files: [
                  {
                      expand: true,
                      src: '*.html',
                      cwd: '/templates',
                      dest: 'build',
                      ext: '.html'

                  }
              ]
          }
      }
  });

  grunt.loadNpmTasks('grunt-nunjucks-2-html');
};

my folder structure looks like this:

```
project
│   Gruntfile.js
│
└───templates
│      index.html
│      foo.html
│  
└───build

```

When i run grunt nunjucks i got the following error:

"Running "nunjucks:render" (nunjucks) task No files specified." So obviously nunjucks can't find my templates. I have no idea where to config the template path, to me my gruntfile seems valid. If you have any idea, I would be glad.

Thank you!

The __dirname variable references the directory the Gruntfile lives in.

You could try using paths: __dirname + '/templates/' or just simply paths: 'templates' as described in the nunjucks-2-html npm documentation .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM