forked from wdgdc/wordpress-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
151 lines (134 loc) · 3.41 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
project: {
assets: '<%= project.root %>/assets',
css : '<%= project.assets %>/css',
fonts : '<%= project.assets %>/fonts',
img : '<%= project.assets %>/img',
inc : '<%= project.root %>/includes',
js : '<%= project.assets %>/js',
lang : '<%= project.root %>/languages',
root : __dirname,
sass : '<%= project.assets %>/sass',
vendor: '<%= project.assets %>/vendor'
},
// Watches for changes and runs tasks
watch: {
options: {
livereload: true,
spawn : false
},
sass: {
files: ['<%= project.sass %>/**/*.scss'],
tasks: ['sass_globbing', 'sass', 'autoprefixer', 'modernizr']
},
css: {
files: ['<%= project.css %>/**/*.css'],
tasks: ['autoprefixer', 'modernizr']
},
img: {
files: ['<%= project.img %>/**/*.{png,jpg,jpeg,gif,svg}'],
tasks: ['newer:imagemin']
},
js: {
files: ['<%= project.js %>/**/*.js'],
tasks: ['jshint', 'modernizr']
},
php: {
files: ['<%= project.root %>/**/*.php']
}
},
// CSS auto prefixer
autoprefixer: {
all: {
expand : true,
flatten: true,
src : '<%= project.css %>/**/*.css',
dest : '<%= project.css %>'
}
},
// Javascript Linter
jshint: {
all: {
src: ['<%= project.js %>/**/*.js', '!**/*.min.js']
},
options: {
jshintrc: true
}
},
// Image compression
imagemin: {
all: {
files: [{
expand: true,
cwd: '<%= project.img %>',
src: '**/*.{png,jpg,jpeg,gif,svg}',
dest: '<%= project.img %>'
}]
}
},
// Sass (Scss) compilation
// $ npm install grunt-sass --save-dev
// create directory /assets/sass
sass: {
all: {
files: [{
expand: true,
cwd: '<%= project.sass %>',
src: ['**/*.scss', '!**/_*.scss'],
dest: '<%= project.css %>',
ext: '.css'
}],
// grunt-sass
options: {
includePaths: [
require('node-bourbon').includePaths,
// $ bower install foundation --save
//'<%= project.vendor %>/foundation/scss'
],
quiet: true,
outputStyle: 'expanded'
}
}
},
// Sass Globbing
sass_globbing: {
all: {
files: {
'<%= project.sass %>/_components.scss':'<%= project.sass %>/components/**/*.scss',
'<%= project.sass %>/_mixins.scss':'<%= project.sass %>/mixins/**/*.scss',
'<%= project.sass %>/_variables.scss':'<%= project.sass %>/variables/**/*.scss'
}
}
},
// Generates a custom modernizr file based on CSS & JS usage
modernizr: {
all: {
devFile: '<%= project.vendor %>/modernizr/modernizr.js',
outputFile: '<%= project.vendor %>/modernizr/modernizr-custom.js',
extensibility: {
domprefixes: true,
prefixes : true
},
matchCommunityTests: true,
files: {
src: ['<%= project.css %>/**/*.css', '<%= project.js %>/**/*.js']
}
}
}
});
// Load up tasks
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-modernizr');
grunt.loadNpmTasks('grunt-sass-globbing');
grunt.loadNpmTasks('grunt-sass');
// Optional tasks
// Default task
grunt.registerTask('default', ['build', 'watch']);
// Build task
grunt.registerTask('build', ['sass_globbing', 'sass', 'autoprefixer', 'modernizr', 'imagemin']);
};