-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
105 lines (99 loc) · 3.76 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
module.exports = function(grunt) {
// load all tasks
require('load-grunt-tasks')(grunt);
var appConfig = {
app: 'src/main/webapp',
product: 'ftl2html',
dist: 'build',
mimgURLPrefix: {
develop: 'http://localhost/hxm',
online: 'http://mimg.127.net/hxm',
test: 'http://mimg.hztest.mail.163.com/hxm'
}
};
// static的版本路径
appConfig.staticPath = '/' + appConfig.product + '/p/20150510';
// app的发布目录
appConfig.appDist = appConfig.dist + '/' + appConfig.product;
// static的发布目录
appConfig.staticDist = appConfig.dist + '/static' + appConfig.staticPath;
grunt.initConfig({
// watch files
watch: {
compass: {
files: ['src/main/webapp/style/scss/**/{,*/}*.{scss,sass}'],
tasks: ['compass:server']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'src/main/webapp/**/{,*/}*.html',
'src/main/webapp/**/{,*/}*.ftl',
'src/main/webapp/js/**/{,*/}*.js',
'src/main/webapp/style/css/**/{,*/}*.css',
'src/main/webapp/style/img/**/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
}
},
// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
sassDir: 'src/main/webapp/style/scss',
cssDir: 'src/main/webapp/style/css',
relativeAssets: false,
assetCacheBuster: false,
raw: 'Sass::Script::Number.precision = 10\nEncoding.default_external = "utf-8"\n'
},
server: {
options: {
sourcemap: true
}
}
},
// The actual grunt server settings
connect: {
options: {
port: 9000,
// Change this to '0.0.0.0' to access the server from outside.
hostname: 'localhost',
livereload: 35129
},
livereload: {
options: {
open: 'http://localhost:9000/demo/',
middleware: function(connect, options) {
var ftl2html = require('./index');
// ftl
var middlewares = [
ftl2html.ftl2html({
configFile: 'src/test/mock/project_config.cfg'
}),
connect().use(
'/style',
connect.static('src/main/webapp/style')
),
connect().use(
'/js',
connect.static('src/main/webapp/js')
),
connect().use(
'/xhr',
ftl2html.static('src/test/mock/xhr')
),
connect.static(appConfig.app)
];
return middlewares;
}
}
}
}
});
grunt.registerTask('default', ['connect:livereload', 'watch']);
grunt.registerTask('convert', 'ftl to html', function(){
var ftl2html = require('./index');
ftl2html.convert('src/test/mock/ftl2html.cfg', 'http://localhost/test1-test.html', '');
ftl2html.convert('src/test/mock/ftl2html.cfg', 'http://localhost/main-test.html', '');
});
};