-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshark-config.js
54 lines (48 loc) · 1.82 KB
/
shark-config.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
const baseconfig = require('./shark-automation-config.js');
const path = require('path');
const fs = require('fs');
const request = require('sync-request');
shark.baseconfig = baseconfig;
shark.webpack = {
entry: 'filename'
};
shark.plugins = {
compile: [{
name: 'compile-js',//如果name和内置的task一致,则会用此配置扩展该内置task。不然无需提供
plugins: {
list: [{
use: 'gulp-babel',//插件名
option: {
presets: ['babel-preset-es2015'].map(require.resolve),
compact: false
}//插件的option参数
}],//gulp插件列表。
merge: 'append'
}
}],
// // 不压缩js
min: [{
name: 'min-js',//如果name和内置的task一致,则会用此配置扩展该内置task。不然无需提供
plugins: {
list: [],//gulp插件列表。
merge: 'replace'
}
}]
};
shark.appConfig = function (app) {
var showdown = require('showdown');
var converter = new showdown.Converter();
app.engine('.html', require('ejs').__express);
// 后缀
app.set('view engine', 'html');
// 模板目录
app.set('views', path.join(__dirname, 'src/main/webapp/examples'));
// head
var headContent = request('GET', 'http://shark.mail.netease.com/shark/static/head.html?v=shark-angular').getBody();
var footContent = request('GET', 'http://shark.mail.netease.com/shark/static/foot.html?v=shark-angular').getBody();
// index.html
app.get('/shark-angularjs/index.html', function (req, res) {
//向页面模板传递参数,可以传递字符串和对象,注意格式
res.render('index', { converter: converter, headContent: headContent, footContent: footContent });
});
}