-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
102 lines (98 loc) · 2.87 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
var
LIVERELOAD_PORT = 35729,
lrSnippet = require('connect-livereload')({
port: LIVERELOAD_PORT
}),
mountFolder = function(connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
connect: {
options: {
port: 1881,
hostname: '127.0.0.1',
open: false
},
livereload: {
options: {
middleware: function(connect) {
return [
lrSnippet,
mountFolder(connect, 'output/www')
];
}
}
}
},
uglify: {
my_target: {
files: [{
expand: true,
src: '**/*.js',
dest: 'output/uglify',
cwd: 'www'
}]
},
other_target: {
files: [{
expand: true,
src: '**/plugins/*.js',
dest: 'output/www/',
cwd: 'www'
}]
}
},
cssmin: {
options: {
shorthandCompacting: false,
roundingPrecision: -1
},
target: {
files: {
'output/uglify/styles/app.css': ['www/styles/app.css'],
}
}
},
htmlmin: {
dist: {
options: { // Target options
removeComments: true,
collapseWhitespace: true
},
files: {
'output/uglify/index.html': 'www/index.html',
'output/www/categories.html': 'www/categories.html',
'output/www/detail.html': 'www/detail.html',
'output/www/items.html': 'www/items.html',
'output/www/login.html': 'www/login.html',
'output/www/menu.html': 'www/menu.html',
'output/www/settings.html': 'www/settings.html'
}
}
},
embed: {
options: {
threshold: '1024KB'
},
bla: {
files: {
'output/www/index.html': 'output/uglify/index.html'
}
},
},
watch: {
files: ['www/**/*.*'],
options: {
livereload: LIVERELOAD_PORT
}
}
});
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
grunt.loadNpmTasks('grunt-embed');
grunt.registerTask('default', ['uglify', 'cssmin', 'htmlmin', 'embed']);
grunt.registerTask('serve', ['default', 'connect', 'watch']);
}