Changeset 469


Ignore:
Timestamp:
07/01/13 02:49:04 (12 years ago)
Author:
hendrikvanantwerpen
Message:

Speed-up build process.

Dropped the development build for generating files in the source
tree. This is a bit more messy, since these files will be checked in
as well. Teh extra copy to build/development was very slow though and
annoying when rapid test cycles were needed. A copy-on-newer function
did not improve much, traversing in Node/grunt seems to take time.

Location:
Dev/trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/Gruntfile.js

    r466 r469  
    22 */
    33
     4var _ = require('underscore');
     5
    46module.exports = function(grunt) {
    57
     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    grunt.registerTask('deploy', []);
     26
     27    // FILES AND FOLDERS
     28   
    629    var srcDir   = 'src/';
    730    var buildDir = 'build/';
    8     var developmentDir = buildDir+'development/';
    9     var productionDir = buildDir+'production/';
     31    var coffeeMap = grunt.file.expandMapping(
     32        [ 'client/qed-client/**/*.coffee', 'server/**/*.coffee' ],
     33        srcDir,
     34        { cwd: srcDir, ext: '.js' });
     35    var lessMap = grunt.file.expandMapping(
     36        [ 'client/qed-client/css/qed.less' ],
     37        srcDir,
     38        { cwd: srcDir, ext: '.css' });
    1039
     40    // TASK CONFIG
     41   
    1142    grunt.initConfig({
     43        'amd-check': {
     44            files: [ srcDir+'client/qed-client/**/*.js' ]
     45        },
    1246        clean: {
    13             development: {
    14                 src: [developmentDir]
    15             },
    16             production: {
    17                 src: [productionDir]
    18             }
     47            build: { src: [buildDir] }
    1948        },
    2049        coffee: {
    21             options: {
    22                 bare: true
    23             },
    24             compile: {
    25                 files: [{
    26                     expand: true,
    27                     cwd: srcDir,
    28                     src: ['client/qed-client/**/*.coffee', 'server/**/*.coffee'],
    29                     dest: developmentDir,
    30                     ext: '.js'
    31                 }]
    32             }
     50            options: { bare: true },
     51            compile: { files: coffeeMap }
    3352        },
    3453        coffeelint: {
    35             compile: {
    36                 options: require('./'+srcDir+'.coffeelint.json'),
    37                 files: [{
    38                     expand: true,
    39                     cwd: srcDir,
    40                     src: ['client/qed-client/**/*.coffee', 'server/**.coffee']
    41                 }]
    42             }
     54            lint: { options: require('./'+srcDir+'.coffeelint.json'),
     55                    files: coffeeMap }
    4356        },
    4457        copy: {
    45             'client-deps': {
    46                 files: [{
    47                     expand: true,
    48                     cwd: srcDir,
    49                     src: ['client/dojo/**', 'client/dijit/**', 'client/dojox/**', 'client/util/**'],
    50                     dest: developmentDir
    51                 }]
    52             },
    53             'server-deps': {
    54                 files: [{
    55                     expand: true,
    56                     cwd: srcDir,
    57                     src: ['node_modules/**'],
    58                     dest: developmentDir
    59                 }]
    60             },
    61             compile: {
    62                 files: [{
    63                     expand: true,
    64                     cwd: srcDir,
    65                     src: ['**', '!**/*.coffee', '!**/*.less', '!node_modules/**', '!client/dojo/**', '!client/dijit/**', '!client/dojox/**', '!client/util/**' ],
    66                     dest: developmentDir
    67                 }]
    68             },
    69             deploy: {
    70                 files: [{
    71                     expand: true,
    72                     cwd: developmentDir,
    73                     src: ['**', '!client/*/**' ],
    74                     dest: productionDir
    75                 }]
    76             }
     58            build: { files: [{ expand: true,
     59                               cwd: srcDir,
     60                               src: ['**', '!client/*/**' ],
     61                               dest: buildDir }]}
    7762        },
    7863        dojo: {
    79             deploy: {
    80                 options: {
    81                     dojo: developmentDir+'client/dojo/dojo.js',
    82                     profile: developmentDir+'client/client.profile.js',
    83                     releaseDir: '../../../'+productionDir
    84                 }
    85             }
     64            build: { options: { dojo: srcDir+'client/dojo/dojo.js',
     65                                profile: srcDir+'client/client.profile.js',
     66                                releaseDir: '../../../'+buildDir }}
    8667        },
    8768        htmlhint: {
    88             options: {
    89                 htmlhintrc: srcDir+".htmlhintrc"
    90             },
    91             compile: {
    92                 files: [{
    93                     expand: true,
    94                     cwd: srcDir,
    95                     src: ['client/*.html', 'client/qed-client/**/*.html']
    96                 }]
    97             }
     69            options: { htmlhintrc: srcDir+".htmlhintrc" },
     70            lint: { files: [{ expand: true,
     71                              cwd: srcDir,
     72                              src: ['client/*.html', 'client/qed-client/**/*.html'] }]}
    9873        },
    9974        jshint: {
    100             options: {
    101                 jshintrc: srcDir+".jshintrc"
    102             },
    103             compile: {
    104                 files: [{
    105                     expand: true,
    106                     cwd: srcDir,
    107                     src: ['client/qed-client/**/*.js', 'server/**.js']
    108                 }]
    109             }
     75            'lint-sources': { options: { jshintrc: srcDir+".jshintrc" },
     76                              files: { src: [ srcDir+'client/qed-client/**/*.js', srcDir+'server/**/*.js' ].concat(exclude(dest(coffeeMap))) }},
     77            'lint-generated': { options: { jshintrc: srcDir+".jshintrc-generated" },
     78                                files: { src: dest(coffeeMap) }}
    11079        },
    11180        less: {
    112             options: {
    113                 strictImports: false,
    114                 dumpLineNumbers: "all"
    115             },
    116             compile: {
    117                 files: [{
    118                     expand: true,
    119                     cwd: srcDir,
    120                     src: ['client/qed-client/css/qed.less'],
    121                     dest: developmentDir,
    122                     ext: '.css'
    123                 }]
    124             }
     81            options: { strictImports: false,
     82                       dumpLineNumbers: "all" },
     83            compile: { files: lessMap }
     84        },
     85        requirejs: {
     86            basePath: srcDir+'client/',
     87            packages: [
     88                { name: "dojo", location: "dojo" },
     89                { name: "dijit", location: "dijit" },
     90                { name: "dojox", location: "dojox" },
     91                { name: "qed-client", location: "qed-client" }
     92            ]
     93        },
     94        usebanner: {
     95            'generated-css': { options: { position: 'top',
     96                                          banner: '/* This CSS file is generated. All edits will be lost on recompile. */'},
     97                               files: { src: dest(lessMap) }},
     98            'generated-js': { options: { position: 'top',
     99                                         banner: '/* This JS file is generated, All edits will be lost on recompile. */'},
     100                               files: { src: dest(coffeeMap) }}
    125101        }
    126102    });
    127103
     104    // LOAD TASKS
     105
     106    grunt.loadNpmTasks('grunt-amd-check');
     107    grunt.loadNpmTasks('grunt-banner');
    128108    grunt.loadNpmTasks('grunt-coffeelint');
    129109    grunt.loadNpmTasks('grunt-contrib-clean');
     
    134114    grunt.loadNpmTasks('grunt-dojo');
    135115    grunt.loadNpmTasks('grunt-htmlhint');
     116    grunt.loadTasks('./grunt-tasks');
    136117
    137     // development tasks
    138     grunt.registerTask('install-deps', ['copy:server-deps', 'copy:client-deps']);
    139     grunt.registerTask('lint', ['jshint:compile', 'htmlhint:compile', 'coffeelint:compile']);
    140     grunt.registerTask('compile', ['lint', 'less:compile', 'coffee:compile', 'copy:compile']);
    141     grunt.registerTask('build', ['clean:development', 'install-deps', 'compile']);
     118    // UTIL FUNCTIONS
    142119
    143     // production tasks
    144     grunt.registerTask('deploy', ['clean:production', 'copy:deploy', 'dojo:deploy']);
     120    function dest(files) {
     121        return _.chain(files)
     122            .map(function(item){ return item.dest; })
     123            .flatten()
     124            .value();
     125    }
    145126
    146     // default task is quick compile
    147     grunt.registerTask('default', ['compile']);
    148 
    149     // util functions
    150 
     127    function exclude(dest) {
     128        return _.map(dest, function(dest){ return '!'+dest; });
     129    }
     130   
    151131};
  • Dev/trunk/package.json

    r466 r469  
    1414    "grunt-contrib-coffee": "~0.7.0",
    1515    "underscore": "~1.4.4",
    16     "grunt-coffeelint": "0.0.6"
     16    "grunt-coffeelint": "0.0.6",
     17    "grunt-banner": "~0.1.4",
     18    "grunt-amd-check": "~0.5.2"
    1719  }
    1820}
  • Dev/trunk/src/.jshintrc

    r464 r469  
    33    "curly": true,
    44    "eqeqeq": true,
     5    "forin": true,
    56    "immed": true,
    67    "indent": 4,
     
    89    "newcap": true,
    910    "noarg": true,
     11    "noempty": true,
    1012    "undef": true,
    1113    "unused": false,
    1214    "strict": false,
    13     "laxcomma": true,
     15    "trailing": false,
    1416
    1517    "loopfunc": true,
     
    1719    "devel": true,
    1820    "node": true,
     21    "browser": true,
     22    "couch": true,
    1923
    2024    "globals": {
Note: See TracChangeset for help on using the changeset viewer.