0

I'm new to grunt js. I'm trying to build multiple tasks with grunt js but each time i got error. How to out from this issue? Here's the my example code.

module.exports = function(grunt){
    grunt.initConfig({
        useminPrepare:{
            html:['app/index.html'],
            options:{
                dest:'build'
            }
        },
        usemin:{html:['build/index.html']},
        copy:{
            task0: {
                src:['app/index.html', 'app/index2.html'],
                dest:['build/index.html', 'build/index2.html']
            }
        }
    });

    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-cssmin');
    grunt.loadNpmTasks('grunt-contrib-uglify');
    grunt.loadNpmTasks('grunt-usemin');

    grunt.registerTask('build',[
        'copy:task0',
        'useminPrepare',
        'concat',
        'cssmin',
        'uglify',
        'usemin'
    ])
}
Sathya
  • 1,704
  • 3
  • 36
  • 58

2 Answers2

1

From the little information you provided, I am guessing that you are running grunt build.

I can see that you are missing some tasks definition as one of the answers points out, but also dest attribute should be a string. You can see it in the documentation: https://github.com/gruntjs/grunt-contrib-copy#usage-examples

Here is example for your case:

        copy:{
            task0: {
                src:['app/index.html', 'app/index2.html'],
                dest: 'build/'
            }
        }

note that the missing tasks are: concat, cssmin, uglify

vlio20
  • 8,955
  • 18
  • 95
  • 180
1

You're missing a semi-colon after registerTask, should be:

grunt.registerTask('build',[
    'copy:task0',
    'useminPrepare',
    'concat',
    'cssmin',
    'uglify',
    'usemin'
]);
Xavier Priour
  • 2,121
  • 1
  • 12
  • 16
  • "missing" semi-colons are [often not a problem at all](http://stackoverflow.com/questions/2846283/what-are-the-rules-for-javascripts-automatic-semicolon-insertion-asi) – James Thorpe May 19 '15 at 14:01