-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
executable file
·114 lines (93 loc) · 3.34 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
'use strict';
module.exports = function(grunt) {
// load all grunt tasks matching the `grunt-*` pattern
// require('load-grunt-tasks')(grunt);
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
function get_banner() {
return '/*! <%= pkg.name %> <%= pkg.version %> <=% grunt.template.today("yyyy-mm-dd") %> */\n';
}
// handles the wordpress theme file
grunt.task.registerTask('wpt', 'A task that sets the version in the WordPress style.css file', function(){
var pkg = grunt.file.readJSON('package.json');
var from_filename = 'style.template.css';
var to_filename = 'style.css';
var contents = grunt.file.read(from_filename);
var obj = {version: pkg.version};
contents = grunt.template.process(contents, {data: obj});
grunt.log.oklns("WordPress style.css updated sucessfully!");
grunt.file.write(to_filename, contents);
});
grunt.initConfig({
// import metadata from the package
pkg: grunt.file.readJSON('package.json'),
// watch for changes and trigger compass, jshint, uglify and livereload
watch: {
compass: {
files: ['resources/css/source/**/*.{scss,sass}'],
tasks: ['compass:dev']
},
js: {
files: 'resources/js/source/**/*.js',
tasks: ['uglify:dev']
}
},
// compass and scss
compass: {
dev: {
options: {
config: 'config.rb',
force: true,
outputStyle: 'expanded',
}
},
production: {
options: {
config: 'config.rb',
force: true,
outputStyle: 'compressed',
}
}
},
// uglify to concat, minify, and make source maps
uglify: {
dev: {
options: {
banner: get_banner(),
compress: false,
beautify: true,
mangle: false
},
files: {
'resources/js/build/main.js': ['resources/js/source/main.js']
}
},
production: {
options: {
banner: get_banner(),
compress: true,
},
files: {
'resources/js/build/main.js': ['resources/js/source/main.js']
}
}
},
// deploy via rsync
rsync: {
options: {
src: "./",
args: ["--verbose"],
exclude: ['.git*', 'node_modules', '.sass-cache', 'Gruntfile.js', 'package.json', '.DS_Store', 'config.rb', '.jshintrc'],
recursive: true,
syncDestIgnoreExcl: true
},
production: {
options: {
dest: "/srv/www/thenexus.tv/public_html/wp-content/themes/coprime/",
host: "[email protected]"
}
}
}
});
grunt.registerTask('deploy', ['compass:production', 'uglify:production', 'wpt', 'rsync:production']);
grunt.registerTask('default', ['compass:dev', 'uglify:dev', 'watch']);
};