-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgruntfile.js
112 lines (88 loc) · 2.78 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
'use strict';
module.exports = function (grunt) {
require('time-grunt')(grunt);
require('jit-grunt')(grunt);
require('load-grunt-tasks')(grunt);
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// browser sync - maps your local site to an ip address that you can visit with other devices on the same network
// run using grunt sync, then copy the External URL.
browserSync: {
dev: {
options: {
proxy: 'local.office-music-player.co.uk'
}
}
},
//jshint config
jshint: {
files: ['assets/js/*.js',],
options: {
'-W030': true,
globals: {
console:true
}
}
},
//sass
sass: {
options: {
sourceMap: true
},
development: {
files: {
"assets/css/app.css": "assets/css/sass/app.scss"
}
}
},
// Auto-prefixer
autoprefixer: {
options: {
browsers: ['opera 12', 'ff 15', 'chrome 25', 'ie 8']
},
single_file: {
src: 'assets/css/app.css',
dest: 'assets/css/app.min.css'
}
},
//watch
watch: {
js: {
files: ['assets/js/*.js', 'assets/js/**/*.js'],
tasks: ['jshint', 'requirejs'],
options: {
spawn: false,
}
},
styles: {
files: ['assets/css/sass/*.scss', 'assets/css/sass/**/*.scss'],
tasks: ['sass']
},
css: {
files: ['assets/css/app.css'],
tasks: ['autoprefixer'],
options: {
livereload: true,
}
}
},
concurrent: {
first: ['sass'],
second: ['autoprefixer']
},
});
// Uncomment this to turn tests on
grunt.registerTask('default', ['concurrent:first', 'concurrent:second', 'watch']);
grunt.registerTask('sync', ['browserSync']);
grunt.event.on('watch', function (action, filepath, target) {
//change the source and destination in the uglify task at run time so that it affects the changed file only
if (target === 'uglify') {
var destFilePath = filepath.replace(/\/js\//, '/js/min/');
destFilePath = destFilePath.replace(/\/min\/(.+)\.js$/, '/min/$1.min.js');
grunt.config('uglify.all.src', filepath);
grunt.config('uglify.all.dest', destFilePath);
} else if (target === 'jshint') {
grunt.config('jshint.files', filepath);
}
});
};