-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
143 lines (130 loc) · 3.48 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
module.exports = function(grunt) {
grunt.registerTask('watch', [ 'watch' ]);
grunt.initConfig({
// Make JS tiny
uglify: {
options: {
mangle: false
},
js: {
files: {
'library/js/main.min.js': ['library/js/main.min.js']
}
}
},
// Minify Images
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'img',
src: ['**/*.{png,jpg,gif,svg}'],
dest: 'img'
}]
}
},
// Compile SCSS
sass: {
dist: {
options: {
style: 'expanded',
loadPath: require('node-bourbon').includePaths
},
files: {
'library/css/style.css' : 'library/scss/style.scss',
'library/css/ie.css' : 'library/scss/ie.scss',
'library/css/login.css' : 'library/scss/login.scss'
}
}
},
// Combine MQ's, but lose critical css
combine_mq: {
target: {
files: {
'library/css/ie.css': ['library/css/ie.css'],
'library/css/style.css': ['library/css/style.css'],
'library/css/login.css': ['library/css/login.css']
},
options: {
beautify: false
}
}
},
// See your changes in the browser as they happen.
browserSync: {
default_options: {
bsFiles: {
src: [
"library/css/*.css",
"*.php,",
"**/*.php,"
]
},
options: {
watchTask: true,
proxy: "fullphatdesign.local"
}
}
},
// Autoprefix
postcss: {
options: {
map: false,
processors: [
require('autoprefixer-core')({
browsers: ['> 20%', 'last 10 versions', 'Firefox > 20']
})
],
remove: false
},
dist: {
src: 'library/css/*.css'
}
},
// Import whole folder into a file
sass_globbing: {
target: {
files: {
'library/scss/components.scss': 'library/scss/components/*.scss'
}
}
},
// Watch for any changes
watch: {
js: {
files: ['library/js/*.js'],
tasks: ['uglify:js']
},
css: {
// Watch sass changes, then process new images and merge mqs
files: ['library/scss/*.scss', 'library/scss/**/*.scss'],
tasks: ['sass_globbing:target', 'sass', 'combine_mq:target', 'postcss:dist', 'browserSync' ]
},
options: {
spawn: false // Very important, don't miss this
}
}
});
// Register everything used
grunt.loadNpmTasks('grunt-newer');
grunt.loadNpmTasks('grunt-combine-mq');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-sass-globbing');
grunt.loadNpmTasks('grunt-postcss');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-browser-sync');
grunt.loadNpmTasks('grunt-contrib-imagemin');
// Run everything with 'grunt', these need to be in
// a specific order so they don't fail.
grunt.registerTask('default', [
'uglify',
'sass_globbing:target', // Glob together needed folders
'sass', // Run sass
'combine_mq', // Combine MQ's
'postcss:dist', // Post Process with Auto-Prefix
'newer:imagemin:dynamic', // Compress all images
'browserSync', // live reload
'watch' // Keep watching for any changes
]);
};