-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathGruntfile.js
134 lines (130 loc) · 4.46 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
var src_root = 'src';
var dest_root = 'www';
var www_browser = 'platforms/browser';
var www_ios = 'platforms/ios'
var www_android = 'platforms/android/assets'
var ts_options = {
module: 'amd',
target: 'es5',
removeComments: true,
sourceMap: false,
references: [
src_root + "/Scripts/typings/*.d.ts",
src_root + "/Scripts/typings/*.ts"
]
};
module.exports = function (grunt) {
grunt.initConfig({
// ts: {
// app: {
// src: [src_root + '/**/*.ts'],
// dest: dest_root,
// options: ts_options
// }
// },
shell: {
client: {
command: 'tsc -p ./src',
options: {
failOnError: false
}
}
},
// 通过connect任务,创建一个静态服务器
connect: {
www: {
options: {
// 服务器端口号
port: 2252,
// 服务器地址(可以使用主机名localhost,也能使用IP)
// hostname: '192.168.1.9',
hostname: '127.0.0.1',
// keepalive: true,
livereload: 26279,
// 物理路径(默认为. 即根目录) 注:使用'.'或'..'为路径的时,可能会返回403 Forbidden. 此时将该值改为相对路径 如:/grunt/reloard。
base: 'www',
open: true,
// protocol: 'https',
}
}
},
copy: {
main: {
files: [
{ expand: true, cwd: src_root, src: ['**/*.html'], dest: dest_root },
{ expand: true, cwd: src_root, src: ['scripts/**/*.js'], dest: dest_root },
{ expand: true, cwd: src_root, src: ['content/css/*.css'], dest: dest_root },
{ expand: true, cwd: src_root, src: ['content/swiper.css'], dest: dest_root },
{ expand: true, cwd: src_root, src: ['content/font/*.*'], dest: dest_root },
{ expand: true, cwd: src_root, src: ['images/**/*.*'], dest: dest_root },
{ expand: true, src: [src_root + '/*.html'], flatten: true, dest: dest_root },
],
app_js: {
files: [{ expand: true, cwd: src_root, src: ['**/*.js'], dest: dest_root }]
}
},
bootbox: {
files: [{ expand: true, cwd: src_root, src: 'core/bootbox.js', dest: dest_root }]
},
www: {
files: [{
expand: true,
src: dest_root + '/**/*.*',
dest: www_ios,
},
{
expand: true,
src: dest_root + '/**/*.*',
dest: www_android,
},
{
expand: true,
src: dest_root + '/**/*.*',
dest: www_browser,
},
]
}
},
less: {
app: {
files: [{
expand: true,
cwd: src_root + '/content/App',
src: ['**/*.less'],
dest: dest_root + '/content/',
ext: '.css'
}]
},
bootstrap: {
files: [{
src: [src_root + '/content/bootstrap-3.3.5/bootstrap.less'],
dest: dest_root + '/content/css/bootstrap.css'
}]
},
chitu: {
files: [{
src: [src_root + '/content/chitu.less'],
dest: dest_root + '/content/chitu.css'
}]
}
},
watch: {
livereload: {
options: {
livereload: 26279 //监听前面声明的端口 35729
},
files: [
`www/**/*`
]
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['shell', 'copy', 'less']);
};