-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
111 lines (108 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
108
109
110
111
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
assets: {
dir: 'assets',
path: '<%= pkg.directories.src %>/<%= assets.dir %>',
styles: {
dir: 'styles',
path: '<%= assets.path %>/<%= assets.styles.dir %>',
files: '<%= assets.styles.path %>/**/*.sass'
},
scripts: {
dir: 'scripts',
path: '<%= assets.path %>/<%= assets.scripts.dir %>',
files: '<%= assets.scripts.path %>/**/*.js'
},
html: {
dir:'.',
path: '<%= pkg.directories.src %>/<%= assets.html.dir %>',
files: '<%= assets.html.path %>/**/*.html'
}
},
sass: {
dist: {
files: [{
expand: true,
cwd: '<%= assets.styles.path %>/sass',
src: ['*.scss'],
dest: '<%= assets.styles.path %>',
ext: '.css'
}]
}
},
postcss: {
options: {
map: true,
processors: [
// require('pixrem')(),
require('autoprefixer')({browsers: 'last 2 versions'}),
require('cssnano')()
]
},
dist: {
src: '<%= assets.styles.path %>/*.css'
}
},
htmlmin: {
dist: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: {
'index.html': '<%= assets.html.path %>/index.html'
}
}
},
copy: {
main: {
files: [
{
expand: true,
cwd:'<%= pkg.directories.src %>',
src: [
'<%= assets.dir %>/**',
'!**/sass/**'
],
dest: './'
}
]
}
},
watch: {
// scripts: {
// files: ['**/*.js'],
// tasks: []
// },
html: {
files: ['<%= assets.html.dir %>/index.html'],
task: ['htmlmin']
},
css: {
files: '<%= assets.styles.dir %>/sass/**/*.scss',
tasks: ['css_compile'],
}
},
browserSync: {
dev: {
bsFiles: {
src : [
'<%= assets.styles.dir %>/**/*.css',
'<%= assets.scripts.dir %>/**/*.js',
'<%= assets.html.dir %>/index.html'
]
},
options: {
watchTask: true,
server: '<%= pkg.directories.src %>'
}
}
}
});
grunt.registerTask('css_compile', ['sass', 'postcss']);
grunt.registerTask('build', ['css_compile', 'htmlmin']);
grunt.registerTask('default', ['build', 'browserSync', 'watch']);
grunt.registerTask('dist', ['build', 'copy'])
};