-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
executable file
·166 lines (144 loc) · 3.85 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
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//Watching Functionality
watch: {
options: {
livereload: true,
},
scripts: {
files: ['js/jsSrc/*.js','js/jsSrc/*/*.js'],
tasks: ['jshint', 'uglify', 'yuidoc'],
options: {
spawn: false
}
},
scss: {
files: ['css/scss/*.scss','css/scss/*/*.scss'],
tasks: ['sass', 'criticalcss', 'postcss'],
options: {
spawn: false,
}
},
images: {
files: ['images/*.{png,jpg,gif}'],
tasks: ['imagemin'],
options: {
spawn: false,
}
}
},
//JS Hinting
jshint: {
all: ['Gruntfile.js', 'js/jsSrc/global.js']
},
//Uglify for JS
uglify: {
dist:{
files:{
'js/global.min.js' : ['js/jsSrc/polyfills/respimage.js', 'js/jsSrc/plugins/lazysizes.js', 'js/jsSrc/libs/shoestring.js', 'js/jsSrc/global.js']
}
}
},
//SASS
sass: {
dist: {
options: {
style: 'expanded',
sourcemap: 'none'
},
files: {
'style.css': 'css/scss/style.scss',
'css/ie8.css': 'css/scss/ie8.scss'
}
}
},
//Critical CSS
criticalcss: {
//Set up a critical CSS file for each major template type
//Home
homePage: {
options: {
url: "http://siren-wordpress.dev/",
outputfile: "css/critical/raw/home.css",
filename: "style.css"
}
},
//Archives - index, taxonomies, archives, etc.
archives: {
options: {
url: "http://siren-wordpress.dev/news/",
outputfile: "css/critical/raw/archives.css",
filename: "style.css"
}
},
//Post
post: {
options: {
url: "http://siren-wordpress.dev/test-post/",
outputfile: "css/critical/raw/post.css",
filename: "style.css"
}
},
//Page
page: {
options: {
url: "http://siren-wordpress.dev/test-page/",
outputfile: "css/critical/raw/page.css",
filename: "style.css"
}
}
},
postcss: {
options: {
map: false, // inline sourcemaps
processors: [
require('autoprefixer')({browsers: 'last 4 versions'}),
require('css-mqpacker')(),
require('cssnano')()
]
},
dist: {
files: [{
src: ['*.css', 'css/*.css', 'css/**/*.css']
}]
}
},
//Image Optimization
imagemin: {
standard: {
files: [{
expand: true,
src: ['**/*.{png,jpg,gif}'],
cwd: 'images/imagesSrc',
dest: 'images/'
}]
}
},
//Javascript documentation
yuidoc: {
all: {
name: 'Siren Core',
description: 'Change this on project start',
version: '0',
url: '',
options: {
paths: ['js/jsSrc/'],
outdir: 'docs/docs-js/'
}
}
}
});
// Load up pluggins
grunt.loadNpmTasks('grunt-contrib-watch'); //Update watcher
grunt.loadNpmTasks('grunt-contrib-uglify'); //Uglify JS
grunt.loadNpmTasks('grunt-contrib-jshint'); //JS Hint
grunt.loadNpmTasks('grunt-contrib-imagemin'); //Image Optimization
grunt.loadNpmTasks("grunt-contrib-yuidoc"); //JS Documentation
grunt.loadNpmTasks('grunt-criticalcss'); //Critical CSS
grunt.loadNpmTasks('grunt-postcss'); //Post CSS
grunt.loadNpmTasks('grunt-contrib-sass');
// Default task(s).
grunt.registerTask('default', ['sass', 'criticalcss', 'postcss' ]);
};