Using Grunt to concatenate multiple js files, but want to split them?

I am new to grunting (literally installed it today and using it) and its great, but I can't work out anything.

I have an angularJs project and I would like to merge all my javascript files into 3 files as a whole.

So I would have

"base" - all provider javascript files for plugins, etc.

"app" - all controllers, etc. used by all users

"admin" - all used controllers, etc., but only ever used by administrators

Now I have grunt installed and configured my task for concat, but how can I use several dest and src attributes?

Grunt file example

grunt.initConfig({
    // Metadata
    pkg: grunt.file.readJSON('package.json'),
    concat: {
        options: {
            stripBanners: true
        },
        dist: {
            src: ['Scripts/jquery-*.js', '!Scripts/jquery-*.min.*', '!Scripts/jquery-*.intellisense.*', 'Scripts/bootstrap.js', 'Scripts/respond.js', 'js/**/*.js'],
            dest: 'dist/app.js'
        },
        distCss: {
            src: ['Content/bootstrap.css', 'Content/site.css'],
            dest: 'dist/app.css'
        }
    },
});

, ugilify, js?

+4
1

, grunt. .

grunt-contrib-concat:

grunt concat . "" , , dist/basic.js, "with_extras" dist/with_extras.js.

grunt.initConfig({
  concat: {
    basic: {
      src: ['src/main.js'],
      dest: 'dist/basic.js',
    },
    extras: {
      src: ['src/main.js', 'src/extras.js'],
      dest: 'dist/with_extras.js',
    },
  },
});

grunt-contrib-uglify, grunt-concat.

+6

All Articles