add new theme flatly to site
[bootswatch] / Gruntfile.js
1 module.exports = function (grunt) {
2         grunt.loadNpmTasks('grunt-recess');
3         grunt.loadNpmTasks('grunt-contrib-concat');
4         grunt.loadNpmTasks('grunt-contrib-clean');
5
6         // Project configuration.
7         grunt.initConfig({
8                 pkg: grunt.file.readJSON('package.json'),
9                 builddir: 'build',
10                 meta: {
11                         banner: '/**\n' +
12                                                 ' * <%= pkg.description %>\n' +
13                                                 ' * @version v<%= pkg.version %> - ' +
14                                                 '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
15                                                 ' * @link <%= pkg.homepage %>\n' +
16                                                 ' * @license <%= pkg.license %>' + ' */'
17                 },
18                 swatch: {
19                         amelia:{}, cerulean:{}, cosmo:{}, cyborg:{}, flatly:{}, journal:{}, readable:{},
20                         simplex:{}, slate:{}, spacelab:{}, spruce:{}, superhero:{}, united:{}
21                 },
22                 clean: {
23                         build: {
24                                 src: ['*/build.less', '*/build-responsive.less',
25                                         '!global/build.less', '!global/build-responsive.less']
26                         }
27                 },
28                 concat: {
29                         dist: {
30                                 src: [],
31                                 dest: ''
32                         }
33                 },
34                 recess: {
35                         dist: {
36                                 options: {
37                                         compile: true,
38                                         compress: false
39                                 },
40                                 files: {}
41                         }
42                 }
43         });
44
45         grunt.registerTask('none', function() {});
46
47         grunt.registerTask('build', 'build a regular theme', function(theme, compress) {
48                 var compress = compress == undefined ? true : compress;
49
50                 var concatSrc;
51                 var concatDest;
52                 var recessDest;
53                 var recessSrc;
54                 var files = {};
55                 var dist = {};
56                 concatSrc = 'global/build.less';
57                 concatDest = theme + '/build.less';
58                 recessDest = '<%=builddir%>/' + theme + '/bootstrap.css';
59                 recessSrc = [ theme + '/' + 'build.less' ];
60
61                 dist = {src: concatSrc, dest: concatDest};
62                 grunt.config('concat.dist', dist);
63                 files = {}; files[recessDest] = recessSrc;
64                 grunt.config('recess.dist.files', files);
65                 grunt.config('recess.dist.options.compress', false);
66
67                 grunt.task.run(['concat', 'recess:dist', 'clean:build',
68                         compress ? 'compress:'+recessDest+':'+'<%=builddir%>/' + theme + '/bootstrap.min.css':'none']);
69         });
70
71         grunt.registerTask('build-responsive', 'build a responsive theme', function(theme, compress) {
72                 var compress = compress == undefined ? true : compress;
73
74                 var concatSrc;
75                 var concatDest;
76                 var recessDest;
77                 var recessSrc;
78                 var files = {};
79                 var dist = {};
80
81                 concatSrc = 'global/build-responsive.less';
82                 concatDest = theme + '/build-responsive.less';
83                 recessDest = '<%=builddir%>/' + theme + '/bootstrap-responsive.css';
84                 recessSrc = [ theme + '/' + 'build-responsive.less' ];
85
86                 dist = {src: concatSrc, dest: concatDest};
87                 grunt.config('concat.dist', dist);
88                 files = {}; files[recessDest] = recessSrc;
89                 grunt.config('recess.dist.files', files);
90                 grunt.config('recess.dist.options.compress', false);
91
92                 grunt.task.run(['concat', 'recess:dist', 'clean:build',
93                         compress ? 'compress:'+recessDest+':'+'<%=builddir%>/' + theme + '/bootstrap-responsive.min.css':'none']);
94         });
95
96         grunt.registerTask('compress', 'compress a generic css', function(fileSrc, fileDst) {
97                 var files = {}; files[fileDst] = fileSrc;
98                 grunt.log.writeln('compressing file ' + fileSrc);
99
100                 grunt.config('recess.dist.files', files);
101                 grunt.config('recess.dist.options.compress', true);
102                 grunt.task.run(['recess:dist']);
103         });
104
105         grunt.registerMultiTask('swatch', 'build a theme, both not responsive and responsive', function() {
106                 var t = this.target;
107                 grunt.task.run('build:'+t, 'build-responsive:'+t);
108         });
109 };