forked from smashingmagazine/old-wordpress-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
181 lines (176 loc) · 3.64 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
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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// gruntfile.js
module.exports = function ( grunt ) {
var path = require( 'path' ),
JAVASCRIPT_DIR = './assets/js/',
LESS_DIR = './assets/less/',
CSS_DIR = './assets/css/';
require( "matchdep" ).filterDev( "grunt-*" ).forEach( grunt.loadNpmTasks );
grunt.initConfig( {
debug: {
options: {
// do not open node-inspector in Chrome automatically
open: false
}
},
// Stylesheets ____________________________
less: {
options: {
paths: CSS_DIR,
report: true
},
src: {
// fetching all *.less-Files in CSS_DIR + 'less/'
// and save them as *.css-Files with compiled css
expand: true,
cwd: LESS_DIR,
src: "*.less",
dest: CSS_DIR,
ext: ".css"
}
},
autoprefixer: {
options: {
browsers: ['last 3 versions', '> 1%'],
report: true
},
theme: {
expand: true,
cwd: CSS_DIR,
dest: CSS_DIR,
src: [
'above-the-fold.css',
'archive-pages.css',
'articles-only.css',
'below-articles.css',
'comments.css',
'contact.css',
'main.css',
'search-results.css'
]
}
},
lineending: {
theme: {
expand: true,
cwd: CSS_DIR,
dest: CSS_DIR,
src: [
'*.css'
],
options: {
eol: 'lf',
overwrite: true
}
}
},
cssmin: {
theme: {
options: {
processImport: true
},
expand: true,
cwd: CSS_DIR,
dest: CSS_DIR,
ext: '.min.css',
src: [
'*.css',
// Exceptions
'!*.min.css'
]
}
},
// JavaScript Task ____________________________
concat: {
options: {
separator: '\n'
},
onload: {
src: JAVASCRIPT_DIR + 'src/onload/*.js',
dest: JAVASCRIPT_DIR + 'onload.js'
}
},
browserify: {
dist: {
options: {
transform: [
[ "babelify", { loose: "all" } ]
]
},
files : {
"./assets/js/ads.js": "./assets/js/src/ads/index.js",
'./assets/js/blocked.js' : './assets/js/src/blocked/index.js',
'./assets/js/lazy-images.js' : './assets/js/src/lazy-images/index.js',
'./assets/js/fastclick.js' : './assets/js/src/fastclick/index.js'
}
}
},
uglify: {
dist: {
expand: true,
cwd: JAVASCRIPT_DIR,
dest: JAVASCRIPT_DIR,
rename: function ( destBase, destPath ) {
// Fix for files with mulitple dots
destPath = destPath.replace( /(\.[^\/.]*)?$/, '.min.js' );
return path.join( destBase || '', destPath );
},
src: [
'*.js',
// Exceptions
'!*.min.js',
'!prism.js',
'!codepen.js'
]
}
},
jshint: {
grunt: {
src: ['Gruntfile.js']
},
onload: {
expand: true,
cwd: JAVASCRIPT_DIR,
src: 'onload.js'
},
blocked: {
expand: true,
cwd: JAVASCRIPT_DIR,
src: 'blocked.js'
},
ads: {
expand: true,
cwd: JAVASCRIPT_DIR,
src: 'ads.js'
}
},
// Watch Task ____________________________
watch: {
themescss: {
files: [
LESS_DIR + '**/*.less'
],
tasks: ['css'],
options: {
dot: true
},
spawn: true,
interval: 2000
},
themejs: {
files: [
JAVASCRIPT_DIR + 'src/onload/*.js'
],
tasks: ['javascript'],
options: {
dot: true
},
spawn: true,
interval: 2000
}
}
} );
grunt.registerTask( 'css', ['less', 'autoprefixer:theme', 'lineending:theme', 'cssmin:theme'] );
grunt.registerTask( 'javascript', ['browserify', 'concat:onload', 'uglify'] );
grunt.registerTask( 'javascript-testing', ['jshint'] );
grunt.registerTask( 'production', ['javascript', 'css'] );
};