-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
157 lines (141 loc) · 4.64 KB
/
Gruntfile.js
File metadata and controls
157 lines (141 loc) · 4.64 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
module.exports = function(grunt) {
// Paths
var cmp_src = 'components/';
var js_src = 'src/js/';
var js_dest = 'wordpress/wp-content/themes/lasse-stefanz/js/';
var coffee_src = 'src/coffee/';
var coffee_dest = js_src;
var css_src = 'src/less/';
var css_dest = 'wordpress/wp-content/themes/lasse-stefanz/';
// Load plugins
grunt.loadNpmTasks('grunt-string-replace');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-coffee');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Copy task
copy: {
main: {
files: [
{
expand: true,
cwd: cmp_src+'fancybox/source/',
src: [
'*.png',
'*.gif'
],
dest: css_dest+'images/'
},
{
expand: true,
cwd: 'external/CSS3MultiColumn/',
src: [
'css3-multi-column.min.js'
],
dest: css_dest+'js/'
}
// {
// expand: true,
// cwd: cmp_src+'background-size-polyfill/',
// src: [
// '*.htc'
// ],
// dest: css_dest
// }
]
}
},
// String replace task
'string-replace': {
main: {
files: {
'wordpress/wp-content/themes/lasse-stefanz/style.css': 'wordpress/wp-content/themes/lasse-stefanz/style.css'
},
options: {
replacements: [
{
pattern: "url('fancybox_",
replacement: "url('images/fancybox_"
}
]
}
}
},
// LESS task
less: {
compile: {
files: {
"wordpress/wp-content/themes/lasse-stefanz/style.css" : 'src/less/style.less'
}
},
compress: {
options: {
yuicompress: true
},
files: {
"wordpress/wp-content/themes/lasse-stefanz/style.css" : 'src/less/style.less'
}
}
},
// Coffee task
coffee: {
main: {
files: {
'src/js/main.js': [coffee_src + 'main.coffee']
}
}
},
// Concat task
concat: {
options: {
separator: ';'
},
main: {
src: [
cmp_src+'jquery-mousewheel/jquery.mousewheel.js',
cmp_src+'fancybox/source/jquery.fancybox.js',
cmp_src+'flexslider-less/jquery.flexslider.js',
js_src+'main.js'
],
dest: js_dest+'<%= pkg.name %>.js'
}
},
// Uglify task
uglify: {
options: {
banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * <%= pkg.website %>/\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %> ' +
'<%= pkg.author %>; <%= pkg.license %> */\n'
},
main: {
src: js_dest+'<%= pkg.name %>.js',
dest: js_dest+'<%= pkg.name %>.min.js'
}
},
// Watch task
watch: {
main: {
files: [coffee_src+'*.coffee', coffee_src+'*/*.coffee', css_src+'*.less', css_src+'*/*.less'],
tasks: ['default'],
options: {
nospawn: true
}
}
}
});
// Default task
grunt.registerTask('style', ['less']);
grunt.registerTask('copy_files', ['string-replace-loop', 'copy']);
grunt.registerTask('scripts', ['coffee', 'concat', 'uglify']);
grunt.registerTask('default', ['style', 'scripts']);
grunt.registerTask('dist', ['copy_files', 'default']);
// Loop through string-replace
// Since string-replace seems broken we must loop a few times manually
grunt.registerTask('string-replace-loop', ['string-replace', 'string-replace', 'string-replace', 'string-replace']);
};