05c4483761a42409e9457f7d071a3afce3e2210b
[fnpeditor.git] / Gruntfile.js
1 /* global module */
2
3 module.exports = function(grunt) {
4     'use strict';
5
6     var build_output_dir = grunt.option('output-dir') || 'build',
7         less_files = {};
8
9     less_files[build_output_dir + '/rng.css'] = 'src/editor/styles/main.less';
10
11     grunt.initConfig({
12         requirejs: {
13           compile: {
14             options: {
15               useStrict: true,
16               baseUrl: 'src/editor',
17               mainConfigFile: 'src/editor/entrypoint.js',
18               out: build_output_dir + '/rng.js',
19               name: 'entrypoint',
20               include: ['libs/require', 'libs/ace/mode-xml'],
21               generateSourceMaps: true,
22
23               // The following two settings are required for source maps to work,
24               // see: http://requirejs.org/docs/optimization.html#sourcemaps
25               preserveLicenseComments: false,
26               optimize: grunt.option('optimize') || 'uglify2'
27             }
28           }
29         },
30         less: {
31             production: {
32                 options: {
33                     paths: [''],
34                     cleancss: true,
35                     relativeUrls: true,
36                     rootpath: 'src/editor/styles/'
37                 },
38                 files: less_files,
39             },
40         },
41         jshint: {
42             all: ['Gruntfile.js', 'src/**/*.js'],
43             options: {
44                 jshintrc: '.jshintrc'
45             }
46         },
47         copy: {
48           resources: {
49             files: [
50               {src: ['libs/bootstrap/img/**'], dest: build_output_dir+'/'},
51             ]
52           }
53         }
54     });
55
56     grunt.loadNpmTasks('grunt-contrib-requirejs');
57     grunt.loadNpmTasks('grunt-contrib-less');
58     grunt.loadNpmTasks('grunt-contrib-jshint');
59     grunt.loadNpmTasks('grunt-contrib-copy');
60
61     grunt.registerTask('build', ['requirejs', 'less:production', 'copy:resources']);
62     grunt.registerTask('lint', ['jshint']);
63     grunt.registerTask('default', ['build']);
64 };