-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
107 lines (96 loc) · 2.63 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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
//Uglify you js
uglify: {
build: {
src: 'src/js/common.js',
dest: 'dist/js/common.min.js'
}
},
//Minify you images
imagemin: {
dynamic: {
files: [{
expand: true,
cwd: 'src/images/',
src: ['**/*.{png,jpg,gif,svg}'],
dest: 'dist/images/'
}]
}
},
//You can to hint you js
jshint:{
options: {
reporter: require('jshint-stylish')
},
main: [
'src/js/*.js'
]
},
//Less to css
less: {
development: {
options: {
paths: ['src/styles'],
compress: true,
yuicompress: true,
optimization: 2
},
files: {
'dist/css/style.css': 'src/styles/style.less'
}
}
},
// Base html build
htmlbuild: {
dev: {
src: 'src/html/*.html',
dest: 'dist/html/',
options: {
basePath: 'src/html/'
}
}
},
//Post process autoprefix
autoprefixer: {
options: {
browsers: ['last 2 versions', 'ie 8', 'ie 9']
},
main: {
expand: true,
flatten: true,
src: 'dist/css/*.css',
dest: 'dist/css/'
}
},
//Auto-watching you changes (type CTRL + S for save changes & it`ll work)
watch: {
//Scripts change
scripts: {
files: ['src/**/*.js'],
tasks: ['jshint','uglify']
},
//Less files change
css: {
files: ['src/**/*.less'],
tasks: ['less','autoprefixer']
},
//HTML files change
html: {
files: ['src/html/*.html'],
tasks: ['htmlbuild']
}
}
});
//Load Tasks
grunt.loadNpmTasks('grunt-html-build');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-imagemin');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-autoprefixer');
grunt.loadNpmTasks('grunt-contrib-watch');
//Register Tasks
grunt.registerTask('default', ['uglify', 'imagemin', 'jshint', 'less', 'autoprefixer','htmlbuild']);
};