forked from cdevroe/unmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
128 lines (114 loc) · 3.92 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
module.exports = function(grunt) {
'use strict';
function loadConfig(path) {
var glob = require('glob'),
object = {},
key;
glob.sync('*', {cwd: path}).forEach(function(option) {
key = option.replace(/\.js$/,'');
object[key] = require(path + option);
});
return object;
}
var asset_version = new Date().getTime();
var js_file_config = {
'assets/js/production/unmark.plugins.js': [
'assets/js/plugins/hogan.js',
'assets/js/plugins/pjax.js',
'assets/js/plugins/fitvids.js'
],
'assets/js/production/unmark.loggedin.js': [
'assets/js/templates/unmark-templates.js',
'assets/js/unmark.js',
'assets/js/unmark.actions.js',
'assets/js/unmark.marks.js',
'assets/js/unmark.client.js',
'assets/js/unmark.init.js',
'assets/js/unmark.touch.js'
],
'assets/js/production/unmark.loggedout.js': [
'assets/js/unmark.js',
'assets/js/unmark.reset.js',
'assets/js/unmark.login.js',
'assets/js/unmark.register.js'
],
'assets/js/production/unmark.bookmarklet.js': [
'assets/js/unmark.js',
'assets/js/unmark.actions.js',
'assets/js/unmark.marks.js',
'assets/js/unmark.add.js',
'assets/js/unmark.init.js'
]
};
// Base Config
var config = {
pkg: grunt.file.readJSON('package.json'),
sass: {
prod: {
options: {
style: 'compressed',
banner: '/*! <%= pkg.name %> - <%=pkg.url %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> - <%= pkg.author %> */ \n'
},
files: {
'assets/css/unmark.css': 'assets/css/unmark.scss',
'assets/css/unmark_welcome.css': 'assets/css/unmark_welcome.scss'
}
}
},
uglify: {
prod: {
options : {
beautify : {
ascii_only : true
},
banner: '/*! <%= pkg.name %> - <%=pkg.url %> - ' + '<%= grunt.template.today("yyyy-mm-dd") %> - <%= pkg.author %> */ \n'
},
files: js_file_config
}
},
concat: {
dev: {
options: {
stripBanners: false,
banner: '/*! DEVELOPMENT VERSION */ \n'
},
files: js_file_config
}
},
"string-replace": {
src: {
files: {
"application/helpers/view_helper.php" : "application/helpers/view_helper.php"
},
options: {
replacements: [{
pattern: /define\("ASSET_VERSION", ('(?:''|[^'])*'|[^',]+)\);/,
replacement: 'define("ASSET_VERSION", "'+asset_version+'");'
}]
}
}
},
watch: {
scripts: {
files: ['assets/js/*.js'],
tasks: ['concat:dev', 'concat:custom']
},
css: {
files: ['assets/css/*.scss'],
tasks: ['sass:prod']
}
}
};
// Look for any option files inside of `/custom/grunt_tasks` folder.
// The file name would be `sass.js` or `watch.js` etc
// If found, extend and overwrite with custom one
grunt.util._.extend(config, loadConfig('./custom/grunt_tasks/'));
// Config the Options
grunt.initConfig(config);
// Load the Tasks
require('load-grunt-tasks')(grunt);
// Register Tasks
grunt.registerTask('default', [ 'sass:prod', 'uglify:prod', 'string-replace' ]); // Default Build for OS Project
grunt.registerTask('dev', [ 'sass:prod', 'concat:dev', 'concat:custom', 'string-replace' ]); // Dev build
grunt.registerTask('production', [ 'sass:prod', 'uglify:prod', 'uglify:custom', 'string-replace' ]); // Default Production Build
};