source: Dev/trunk/Gruntfile.js @ 472

Last change on this file since 472 was 471, checked in by hendrikvanantwerpen, 12 years ago

Fixed build dir location.

File size: 4.6 KB
RevLine 
[464]1/** Gruntfile - control build and deploy tasks
[453]2 */
[443]3
[469]4var _ = require('underscore');
5
[443]6module.exports = function(grunt) {
7
[469]8    // TASKS
9
10    grunt.registerTask('default', ['compile']);
11    grunt.registerTask('compile', ['jshint:lint-sources'
12                                  ,'htmlhint:lint'
13                                  ,'coffeelint:lint'
14                                  ,'less:compile'
15                                  ,'usebanner:generated-css'
16                                  ,'coffee:compile'
17                                  ,'usebanner:generated-js'
18                                  ,'jshint:lint-generated'
19                                  //,'amd-check' // too smart about plugins, r.js can't find them
20                                  ]);
21    grunt.registerTask('build', ['clean:build'
22                                ,'copy:build'
23                                ,'dojo:build'
24                                ]);
25
26    // FILES AND FOLDERS
27   
[464]28    var srcDir   = 'src/';
[463]29    var buildDir = 'build/';
[469]30    var coffeeMap = grunt.file.expandMapping(
31        [ 'client/qed-client/**/*.coffee', 'server/**/*.coffee' ],
32        srcDir,
33        { cwd: srcDir, ext: '.js' });
34    var lessMap = grunt.file.expandMapping(
35        [ 'client/qed-client/css/qed.less' ],
36        srcDir,
37        { cwd: srcDir, ext: '.css' });
[453]38
[469]39    // TASK CONFIG
40   
[443]41    grunt.initConfig({
[469]42        'amd-check': {
43            files: [ srcDir+'client/qed-client/**/*.js' ]
44        },
[458]45        clean: {
[469]46            build: { src: [buildDir] }
[458]47        },
[463]48        coffee: {
[469]49            options: { bare: true },
50            compile: { files: coffeeMap }
[453]51        },
[466]52        coffeelint: {
[469]53            lint: { options: require('./'+srcDir+'.coffeelint.json'),
54                    files: coffeeMap }
[466]55        },
[463]56        copy: {
[469]57            build: { files: [{ expand: true,
58                               cwd: srcDir,
59                               src: ['**', '!client/*/**' ],
60                               dest: buildDir }]}
[458]61        },
[453]62        dojo: {
[469]63            build: { options: { dojo: srcDir+'client/dojo/dojo.js',
64                                profile: srcDir+'client/client.profile.js',
[471]65                                releaseDir: '../../'+buildDir }}
[453]66        },
67        htmlhint: {
[469]68            options: { htmlhintrc: srcDir+".htmlhintrc" },
69            lint: { files: [{ expand: true,
70                              cwd: srcDir,
71                              src: ['client/*.html', 'client/qed-client/**/*.html'] }]}
[443]72        },
73        jshint: {
[469]74            'lint-sources': { options: { jshintrc: srcDir+".jshintrc" },
75                              files: { src: [ srcDir+'client/qed-client/**/*.js', srcDir+'server/**/*.js' ].concat(exclude(dest(coffeeMap))) }},
76            'lint-generated': { options: { jshintrc: srcDir+".jshintrc-generated" },
77                                files: { src: dest(coffeeMap) }}
[443]78        },
[453]79        less: {
[469]80            options: { strictImports: false,
81                       dumpLineNumbers: "all" },
82            compile: { files: lessMap }
83        },
84        requirejs: {
85            basePath: srcDir+'client/',
86            packages: [
87                { name: "dojo", location: "dojo" },
88                { name: "dijit", location: "dijit" },
89                { name: "dojox", location: "dojox" },
90                { name: "qed-client", location: "qed-client" }
91            ]
92        },
93        usebanner: {
94            'generated-css': { options: { position: 'top',
95                                          banner: '/* This CSS file is generated. All edits will be lost on recompile. */'},
96                               files: { src: dest(lessMap) }},
97            'generated-js': { options: { position: 'top',
98                                         banner: '/* This JS file is generated, All edits will be lost on recompile. */'},
99                               files: { src: dest(coffeeMap) }}
[443]100        }
101    });
102
[469]103    // LOAD TASKS
104
105    grunt.loadNpmTasks('grunt-amd-check');
106    grunt.loadNpmTasks('grunt-banner');
[466]107    grunt.loadNpmTasks('grunt-coffeelint');
[458]108    grunt.loadNpmTasks('grunt-contrib-clean');
[463]109    grunt.loadNpmTasks('grunt-contrib-coffee');
[453]110    grunt.loadNpmTasks('grunt-contrib-copy');
111    grunt.loadNpmTasks('grunt-contrib-jshint');
[443]112    grunt.loadNpmTasks('grunt-contrib-less');
[453]113    grunt.loadNpmTasks('grunt-dojo');
[443]114    grunt.loadNpmTasks('grunt-htmlhint');
[469]115    grunt.loadTasks('./grunt-tasks');
[443]116
[469]117    // UTIL FUNCTIONS
[464]118
[469]119    function dest(files) {
120        return _.chain(files)
121            .map(function(item){ return item.dest; })
122            .flatten()
123            .value();
124    }
[464]125
[469]126    function exclude(dest) {
127        return _.map(dest, function(dest){ return '!'+dest; });
128    }
129   
[443]130};
Note: See TracBrowser for help on using the repository browser.