The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Concatenating Your Javascript with grunt-contrib-concat

Concatenating Your Javascript with grunt-contrib-concat

2:02
You can use Grunt to combine all of your Javascript files into a single concatenated file.
Watch this lesson now
Avatar
egghead.io

You can use Grunt to combine all of your Javascript files into a single concatenated file.

Avatar
Julie

Gruntfile.js if this is of use to others:

module.exports = function (grunt) {

    grunt.initConfig({
        stylus: {
            compile: {
                // so that it doesn't minify
                options: {compress: false},
                files: {
                    'css/app.css': 'styl/app.styl'
                }
            }
        },
        watch: {
            stylus: {
                files: ['styl/**.styl'],
                tasks: ['stylus:compile']
            },
            css: {
                options: {livereload: true},
                files: ['css/**.css']
            },
            html: {
                options: {livereload: true},
                files: ['**.html']
            },
            script: {
                options: {livereload: true},
                files: ['**.js']
            }
        },
        concat: {
            js: {
                src: ['d3.js','js/app.js','**.js'],
                dest: 'build/app.js'
            }
        }

    });

    grunt.loadNpmTasks('grunt-contrib-stylus');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.registerTask('build', []);

};
In reply to egghead.io
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?