Closed jayenashar closed 8 years ago
See https://github.com/patrickkettner/grunt-compile-handlebars/issues/56
This is the behavior because you may have multiple files that are being appended to during the run. In addition, If you want to remove files between runs, I suggest grunt-contrib-clean
Once you install it ( npm install grunt-contrib-clean --save-dev
), you should add the task to your Gruntfile.js
. This is how mine looks like:
module.exports = function(grunt) {
grunt.initConfig({
clean: {
folder: ['src/*'],
},
'compile-handlebars': {
index: {
files: [{
src: 'handlebars/index.handlebars',
dest: 'src/index.html'
}],
partials: 'handlebars/partials/*.handlebars',
templateData: {}
}
}
});
grunt.registerTask('default', ['clean', 'compile-handlebars']);
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-compile-handlebars');
};
After that, running the default task will delete the files in the directory before compiling them again.
thanks for that. seems inconsistent with plugins like uglify which concatenate src and write the file once. i just patched the plugin to never append.
I agree with jayenashar. Could there be an option for overwriting instead of appending?
+1
+1
Agree with @jayenashar - This is the only Grunt plugin I've used which appends to destination files like this.
as mentioned in #54
This is the behavior because you may have multiple files that are being appended to during the run. In addition, If you want to remove files between runs, I suggest grunt-contrib-clean
Gruntfile.js:
not sure why this appends to
src/main/webapp/index.html
instead of writing it it...