-
Notifications
You must be signed in to change notification settings - Fork 8
/
Gruntfile.js
83 lines (75 loc) · 2.16 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//Gruntfile
module.exports = function(grunt) {
// requirejs compile options
var compileOptions = {
mainConfigFile: 'app/scripts/main.js',
baseUrl: 'app/scripts',
include: ['main'],
out: 'dist/main.min.js',
removeCombined: false,
findNestedDependencies: true,
//Removes console.logs for production
onBuildWrite: function (moduleName, path, contents) {
if(/(.*)js\/modules\/(.*)/.test(path)) return contents.replace(/console.log(.*);/g, ';');
return contents;
}
}
//Initializing the configuration object
grunt.initConfig({
// Task configuration
less: {
development: {
options: {
compress: false, // no minification in dev
strictMath: true
},
files: {
//compiling base.less into styles.css
"./app/styles/styles.css":"./app/styles/base.less"
}
},
production: {
options: {
cleancss: true, // minify css
// compress: true, // minify css
strictMath: true
},
files: {
//compiling base.less into main.min.css
"./dist/main.min.css": "./app/styles/base.less"
}
}
},
requirejs: {
compile: {
options : compileOptions
}
},
watch: {
less: {
// Watch all .less files from the styles directory)
files: ['app/styles/*.less'],
tasks: ['less'],
// Reloads the browser
options: {
livereload: true
}
},
requirejs: {
// Watch only main.js so that we do not constantly recompile the .js files
files: [ 'app/scripts/main.js' ],
tasks: [ 'requirejs' ],
// Reloads the browser
options: {
livereload: true
}
}
}
});
// Plugin loading
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-watch');
// Task definition
grunt.registerTask('default', ['watch']);
};