Question

Can I use properties (similar to ANT) to specify the destination directory for copying files using grunt-contrib-copy, for instance:

  // Project Configuration
  grunt.initConfig({
    properties: {
        /* Templates Directory for Express.js */
        /* (Destination Directory for hjs files in nanoc_outputdir) */
        express_templates_directory: './templates',

        /* Express public directory for static files */
        /* (Here we will hold static files like *.css and images ) */
        express_public_directory: './public',

        express_css: '<%= properties.express_public_directory %>/stylesheets',

        /* The directory where nanoc outputs our templates */
        nanoc_outputdir: './output'  
     },
     /* ... */
    copy: {
            cptemplates: {
                files: [
                         {expand: true, cwd: '<%= properties.nanoc_outputdir %>/', src:'*.html', dest: '<%= properties.express_templates_directory  %>/'}
        ]
    }
} */
Was it helpful?

Solution

I'm not sure if there's a way to make a properties task, but you definitely can make it a variable:

var properties = {
  /* Templates Directory for Express.js */
  /* (Destination Directory for hjs files in nanoc_outputdir) */
  express_templates_directory: './templates',

  /* Express public directory for static files */
  /* (Here we will hold static files like *.css and images ) */
  express_public_directory: './public',

  express_css: './public/stylesheets',

  /* The directory where nanoc outputs our templates */
  nanoc_outputdir: './output',
};

grunt.initConfig({
  copy: {
    cptemplates: {
      files: [
        {
          expand: true,
          cwd: properties.nanoc_outputdir,
          src: '*.html',
          dest: properties.express_templates_directory,
        }
      ]
    }
  }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top