forked from ss1121/FKP-REST
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapper.js
More file actions
41 lines (34 loc) · 1.08 KB
/
mapper.js
File metadata and controls
41 lines (34 loc) · 1.08 KB
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
/**
* Module dependencies.
*/
var fs = require('fs')
var views = require('co-views-helpers');
var config = require('../config')
// 从map.json拿取获取静态资源 hash 名称
var getMapJson = function(stat){
var mapJson;
if(!stat) stat = 'pro';
console.log('===============');
console.log('===============');
console.log('===============');
console.log(stat)
if(fs.existsSync(config.mapJson)||fs.existsSync(config.mapDevJson))
return mapJson = stat === 'dev' ? JSON.parse(fs.readFileSync(config.mapDevJson,'utf-8')) : JSON.parse(fs.readFileSync(config.mapJson,'utf-8'));
else
return false;
}
//设置全局变脸_mapper
var getMapper = function(stat){
var _mapper={};
var mapper = getMapJson(stat);
if(!mapper)
return false;
_mapper = mapper;
_mapper.commonJs = _mapper.commonDependencies.js;
_mapper.commonCss = _mapper.commonDependencies.css;
_mapper.pageJs = _mapper.dependencies.js;
_mapper.pageCss = _mapper.dependencies.css;
_mapper.length = Object.keys(mapper).length;
return _mapper;
}
module.exports = getMapper