alanshaw / grunt-include-replace

Grunt task to include files and replace variables. Allows for parameterised includes.
MIT License
200 stars 45 forks source link

Not creating dist directory #35

Closed nareshbhatia closed 10 years ago

nareshbhatia commented 10 years ago

Just started to look at this plugin. Looks really useful, except that I am not able to make it work. The includereplace:dist task runs, but the dist directory is not created. Here's my grunt file: what am I doing wrong?

module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({

    // Remove the build directory
    clean: {
      clean: ['dist/']
    },

    // Build the site using grunt-include-replace
    includereplace: {
      dist: {
        options: {
          includesDir: 'inc/'
        },
        src: '*.html',
        dest: 'dist/'
      }
    }
  });

  // Load plugins used by this task gruntfile
  grunt.loadNpmTasks('grunt-include-replace');
  grunt.loadNpmTasks('grunt-contrib-clean');

  // Task definitions
  grunt.registerTask('default', ['clean', 'includereplace:dist']);
};
nareshbhatia commented 10 years ago

Found the problem. My index.html file was in a sub-directory called "pages". There was no html file in the project directory, so there were no files being processed. Now I understand that src: "*.html" literally means scan for html files in the current directory only.

I suggest to include a very simple but complete example in an examples directory, including a package.json file and a Gruntfile.js. I know there are plenty of examples in the test directory but it is difficult to know which is the simplest and I did not realize that the root level Gruntfile.js included the options for each test.

Also please let me know how can I push my index.html source file in to a directory called src. I changed my grunt file to say src: 'src/*.html' but what that does is to generate the transformed index.html under dist/src, instead of dist.

alanshaw commented 10 years ago

See https://github.com/alanshaw/grunt-include-replace/pull/24