Reputation: 10791
I have this task in my gruntfile:
jade: {
compile: {
options: {
client: false,
pretty: true,
data: {
section: grunt.file.readJSON('json/section.json')
}
},
files: [ {
cwd: "app/views",
src: "**/*.jade",
dest: "build/templates",
expand: true,
ext: ".html"
} ]
}
}
However when I add this snippet to a js file jade.js like so:
module.exports = {
compile: {
options: {
client: false,
pretty: true,
data: {
section: grunt.file.readJSON('json/section.json')
}
},
files: [ {
cwd: "app/views",
src: "**/*.jade",
dest: "build/templates",
expand: true,
ext: ".html"
} ]
}
}
I get the error ReferenceError: grunt is not defined
although I have the following setup:
aliases.yaml
default:
- 'jade'
- 'sass'
- 'watch
FOLDER STRUCTURE
/grunt
aliases.yaml
jade.js
sass.js
watch.js
Gruntfile.js
module.exports = function(grunt) {
// load grunt config
require('load-grunt-config')(grunt);
};
I have load-grunt-config and load-grunt-tasks both installed.
Upvotes: 0
Views: 153
Reputation: 2121
If you want to use grunt
in your config, you have to use the function form for the jade.js file:
module.exports = function (grunt, options) {
return {
compile: {
options: {
client: false,
pretty: true,
data: {
section: grunt.file.readJSON('json/section.json')
}
},
files: [ {
cwd: "app/views",
src: "**/*.jade",
dest: "build/templates",
expand: true,
ext: ".html"
} ]
}
}
}
Upvotes: 1