This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
87 lines (83 loc) · 2.51 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
84
85
86
87
/**
* Boilerplate Gruntfile.js
*/
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('load-grunt-tasks')(grunt);
/**
* Setup some basic variables to use later
*/
var pkg = grunt.file.readJSON('package.json');
var slug = process.cwd().substr(process.cwd().lastIndexOf('/') + 1);
var remote = 'git@github.com:PageLines-Team/' + slug + '.git'
var build_msg = grunt.option('message') || ''
/**
* Main Grunt config start
*/
grunt.initConfig({
// clean task, an array of folders to clean
clean: ['dist','src'],
// watch task, in this case we just watch one file build.less and when it changes run less compiler
watch: {
lessMain: {
// what files/folder we watching?
files: [ 'build.less' ],
// tasks to run in order when something changes
tasks: ['less:compileMain'],
options: {
nospawn: true,
}
}
},
// The LESS task, compiles build.less into a usable style.css file
less: {
compileMain: {
src: 'build.less',
dest: 'style.css',
options: {
strictMath: true,
sourceMap: false }
}
},
// copy task, copy all files into a dist folder.
// uses pkg.copyIgnores variable which is an array of files and folders to ignore.
// They are set in package.json folder
copy: {
build: {
files: [ {
expand: true,
src: [ '**', pkg.copyIgnores ],
dest: 'dist/',
filter: 'isFile'
} ]
}
},
// build task, pushes contents of dist folder to remote 'build' branch.
buildcontrol: {
options: {
dir: 'dist',
commit: true,
push: true,
message: build_msg + ' [Built from commit "%sourceCommit%"]'
},
production: {
options: {
remote: remote,
branch: 'build'
}
},
staging: {
options: {
remote: remote,
branch: 'staging'
}
}
}
});
// Default grunt task,
grunt.registerTask( 'default', [ 'clean', 'less', 'watch'] );
// grunt build task for production
grunt.registerTask( 'build', [ 'clean', 'less', 'copy:build', 'buildcontrol:production'] );
// grunt build task for staging
grunt.registerTask( 'stage', [ 'clean', 'less', 'copy:build', 'buildcontrol:staging'] );
}