forked from luoliqiang/worktile
/
Gruntfile.js
52 lines (47 loc) · 1.91 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
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * poem v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
' * <%= grunt.template.today("yyyy-mmmm-dd") %> <%= pkg.author %>\n' +
' * Licensed under the <%= pkg.license %> license\n' +
' */\n',
less: {
develop: {
expand: true,
ext: '.css',
flatten: true,
cwd: 'public/less',
src: 'poem.less',
dest: 'public/css/'
}
},
connect: {
server: {
options: {
port: 8080,
hostname: '127.0.0.1',
base: '.',
livereload: 35729,
open: true
}
}
},
watch: { //如果只用watch插件,需要自己启动一个页面服务器,并且在页面添加一行script标签且端口指向livereoad的服务器,
//这样两个服务器通信,修改文件时livereoad服务器会通知静态页面页面服务器(或者说是浏览器)刷新界面,
options: {
livereload: 35729,
cwd: 'public/less/' //相对路径
},
files: ['**/*.less'],
tasks: ['lessdev']
}
});
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.registerTask('lessdev', ['less']); //注意一定不能把执行名称写成less否则执行无反应
grunt.registerTask('watchless', ['watch']); //注意一定不能把执行名称写成less否则执行无反应
grunt.registerTask('livereload', ['connect', 'watch']);//只能单独的静态文件使用,无法和express通用
}