1.

How Does Gruntfile.js Uses Package.json?

Answer»

Task configuration is specified in your Gruntfile via the grunt.initConfig method. Inside of grunt.initConfig(), we READ the information from package.json and SAVED it to a pkg PROPERTY. With this, we can use the attributes from our package.json file. We can call the name of our PROJECT using pkg.name and the version with pkg.version.

  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. pkg: grunt.file.readJSON('package.json')
  4. });
  5. };

Task configuration is specified in your Gruntfile via the grunt.initConfig method. Inside of grunt.initConfig(), we read the information from package.json and saved it to a pkg property. With this, we can use the attributes from our package.json file. We can call the name of our project using pkg.name and the version with pkg.version.



Discussion

No Comment Found