-
Notifications
You must be signed in to change notification settings - Fork 0
/
GruntFile.js
85 lines (76 loc) · 2.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
module.exports = function(grunt){
//Configure Grunt
grunt.initConfig({
// Get the configuration info from package.json
pkg: grunt.file.readJSON('package.json'),
// Configure jshint to validate js files
jshint: {
options: {
// Use jshint-stylish to make our errors look and read good
reporter: require('jshint-stylish')
},
// When this task is run, lint the Gruntfile and all js files in src
build: ['gruntfile.js', 'src/***/*.js']
},
// Configure uglify to minify js files
uglify: {
options: {
// This will add a nice comment to the top of our minified file
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> \n*/\n'
},
build: {
files: {
// This will select all js files in src and minify them.
'build/js/sample.min.js' : 'src/***/*.js'
}
}
},
// Compile sass stylesheets to css
sass: {
options: {
implementation: require('node-sass'),
sourceMap: true
},
build: {
files: {
'build/css/main.css' : 'src/scss/main.scss'
}
}
},
// Configure cssmin to minify css files
cssmin: {
options: {
banner: '/*\n <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> \n*/\n'
},
build: {
files: {
'build/css/main.min.css' : 'build/css/main.css'
}
}
},
// Configure watch to auto update
watch: {
// For stylesheets, watch css and sass files
// Only run sass and cssmin
stylesheets: {
files: ['src/**/*.css', 'src/**/*.scss'],
tasks: ['sass', 'cssmin']
},
// For scripts, run jshint and uglify
scripts: {
files: 'src/**/*.js', tasks: ['jshint', 'uglify']
}
}
});
// Load Grunt packages.
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-watch');
// Register Task
grunt.registerTask('devcss', ['sass', 'watch']);
grunt.registerTask('minify', ['sass', 'cssmin']);
grunt.registerTask('devjs', ['jshint', 'uglify']);
grunt.registerTask('default', ['jshint', 'uglify', 'sass', 'cssmin']);
};