-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
82 lines (78 loc) · 3.7 KB
/
Copy pathGruntfile.js
File metadata and controls
82 lines (78 loc) · 3.7 KB
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
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// Task: copy all files from 'raw-static-resources' to the 'static-resources' exclude *.coffee and *.scss files
copy: {
main: {
src: ['**/*' , '!**/*.coffee', '!**/*.scss', '!**/readme'], // copy masks
expand: true,
cwd: 'raw-static-resources', // source directory
dest: 'static-resources' // target directory
}
},
// Task: compile all coffee files and put them to the target directory
coffee: {
dist: {
files: [{
expand: true,
cwd: 'raw-static-resources', // source directory
src: ['**/*.coffee'], // file mask
dest: 'static-resources', // target directory
ext: '.js' // final extension
}]
}
},
sass: {
dist: {
files: [{
expand: true,
cwd: 'raw-static-resources', // source directory
src: ['**/*.scss'], // file mask
dest: 'static-resources', // target directory
ext: '.css' // final extension
}]
}
},
// Task: watch for adding, changing and deleting files
watch: {
coffee: {
files: 'raw-static-resources/**/*.coffee', // target directory
tasks: ['coffee'] // target task
},
css: {
files: 'raw-static-resources/**/*.scss', // target directory
tasks: ['sass'] // target task
},
other: {
files: ['raw-static-resources/**', 'raw-static-resources/**/!*.(scss)', 'raw-static-resources/**/!(*.coffee)'],
tasks: ['clean', 'copy', 'coffee', 'sass']
}
},
clean: ["static-resources"]
});
// grunt.event.on('watch', function(action, filepath, target) {
// if (action === 'deleted') {
// grunt.log.write('action: ' + action + ' ');
// grunt.log.write('filepath: ' + filepath + ' ');
// grunt.log.write('target: ' + target + ' ');
// extention = filepath.substr(filepath.lastIndexOf("."), filepath.size);
// grunt.log.write('extention: ' + extention + ' ');
// fileToDelete = filepath.substr(4, filepath.lastIndexOf(".") - 4);
// if (extention === '.scss') {
// fileToDelete = fileToDelete + '.css';
// }
// if (extention === '.coffee') {
// fileToDelete = fileToDelete + '.js';
// }
// grunt.log.write('fileToDelete: ' + fileToDelete + ' ');
//
// grunt.file.delete(fileToDelete);
// }
// });
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('default', ['clean', 'copy', 'coffee', 'sass', 'watch'])
};