-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
201 lines (182 loc) · 5.08 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
module.exports = function (grunt) {
grunt.initConfig({
concat: {
options: {
separator: ';',
},
dist: {
src: ['src/js/commonscript.js', 'src/js/desktop.js', 'src/js/siteroot.js'],
dest: 'dist/assets/js/all.js',
}
},
copy: {
main: {
expand: true,
cwd: 'src',
src: '*.html',
dest: 'dist/',
},
css: {
expand: true,
cwd: 'src/css',
src: '*.css',
dest: 'dist/assets/css/',
},
headers: {
expand: true,
cwd: 'src',
src: '_headers',
dest: 'dist/',
}
},
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: {
'dist/assets/css/all.css': ['src/css/globalltr.css', 'src/css/sitemaster.css']
}
}
},
imagemin: { // Task
dynamic: { // Another target
files: [{
expand: true, // Enable dynamic expansion
cwd: 'src/img/', // Src matches are relative to this path
src: ['**/*.{png,jpg,gif}'], // Actual patterns to match
dest: 'dist/assets' // Destination path prefix
}]
}
},
// uglify: {
// options: {
// banner: '/*! This is the Banner: <%= grunt.template.today("yyyy-mm-dd") %> */\n'
// //banner: '/*! This is teh Banner <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
// },
// build: {
// src: 'src/<%= pkg.name %>.js',
// dest: 'build/<%= pkg.name %>.min.js'
// }
// },
csscomb: {
dist: {
files: {
'dist/assets/css/all_comb.css': ['dist/assets/css/all.css'],
}
},
},
clean: {
build: {
src: ['dist/*']
}
},
critical: {
dist: {
options: {
base: './',
css: [
'dist/assets/css/all.css'
],
},
// The source file
// src: 'http://garnerp.netlify.com/', //dist/index.html
src: 'dist/index.html',
// The destination file
dest: 'dist/result.html'
},
dist_head: {
options: {
base: './',
css: [
'dist/assets/css/all.css'
],
},
// The source file
// src: 'http://garnerp.netlify.com/', //dist/index.html
src: 'dist/index_head.html',
// The destination file
dest: 'dist/result_head.html'
}
},
postcss: {
options: {
// map: true, // inline sourcemaps
// or
map: {
inline: false, // save all sourcemaps as separate files...
annotation: 'dist/assets/css/maps/' // ...to the specified directory
},
processors: [
// require('pixrem')(), // add fallbacks for rem units
require('autoprefixer')({ browsers: 'last 2 versions' }), // add vendor prefixes
require('cssnano')() // minify the result
]
},
dist: {
src: 'dist/assets/css/all.css'
}
},
/*
critical: {
dist: {
options: {
base: './',
dimensions: [{
width: 1300,
height: 900
},
{
width: 500,
height: 900
}]
},
files: [
{ src: ['dist/index.html'], dest: 'dist/index2.html' }
]
}
}
*/
// The source file
// src: 'dist/index.html',
// The destination file
// url: 'http://garnerp.netlify.com/',
// width: 1200,
// height: 900,
// outputfile: "critical.css",
// filename: "/path/to/local/all.css", // Using path.resolve( path.join( ... ) ) is a good idea here
// buffer: 800*1024,
// ignoreConsole: false
// }
// }
// }
/*
criticalcss: {
custom: {
options: {
url: "dist/index.html",
width: 1200,
height: 900,
outputfile: "dist/critical.css",
filename: "dist/assets/css/all.css", // Using path.resolve( path.join( ... ) ) is a good idea here
ignoreConsole: false
}
}
},
*/
});
// Load the plugins
grunt.loadNpmTasks('grunt-critical');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-csscomb');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-postcss');
// Default tasks.
// removed cssmin that was after imagemin
grunt.registerTask('default', ['clean', 'imagemin', 'cssmin', 'copy', 'concat', 'postcss', 'critical']);
};