-
Notifications
You must be signed in to change notification settings - Fork 4
/
Gruntfile.js
93 lines (85 loc) · 1.71 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
module.exports = (grunt) => {
const pkg = grunt.file.readJSON('package.json')
const banner = `${pkg.title} — ${pkg.description}
Version: ${pkg.version}
Date: ${grunt.template.today('dd.mm.yyyy')}
Author: ${pkg.author.name}
HomePage: ${pkg.homepage}
License: ${pkg.license}`
grunt.initConfig({
// less build
less: {
dist: {
files: {
'dist/legrid.css': 'src/legrid.less'
}
}
},
// media queries packer
css_mqpacker: {
main: {
options: {
map: false,
sort: false
},
expand: true,
src: 'dist/legrid.css'
}
},
// postcss (autoprefixer, sorting, cssnano)
postcss: {
dist: {
options: {
map: false,
processors: [
require('autoprefixer')(),
require('postcss-sorting')({
'sort-order': 'csscomb'
}),
require('postcss-merge-rules')(),
require('postcss-flexbugs-fixes'),
require('postcss-banner')({
banner: banner,
important: true
})
]
},
src: 'dist/legrid.css',
dest: 'dist/legrid.css'
},
compress: {
options: {
map: false,
processors: [
require('cssnano')({
removeComments: {
removeAll: true
}
})
]
},
src: 'dist/legrid.css',
dest: 'dist/legrid.min.css'
}
},
// Watch
watch: {
less: {
files: 'src/**/*.less',
tasks: ['css']
},
dev: {
files: 'src/**/*.less',
tasks: ['dev']
}
}
})
// Load npm plugins to provide necessary tasks.
require('load-grunt-tasks')(grunt, {
pattern: ['grunt-*']
})
// Default task.
grunt.registerTask('default', ['css'])
grunt.registerTask('dev', ['less', 'css_mqpacker'])
grunt.registerTask('css', ['less', 'css_mqpacker', 'postcss'])
}