This repository was archived by the owner on Mar 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex_old.js
More file actions
125 lines (115 loc) · 4.07 KB
/
index_old.js
File metadata and controls
125 lines (115 loc) · 4.07 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
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
module.exports = function (config) {
var mode = 'default', fis = require('fis3');
mode = config.mode ? config.mode : mode;
fis.require.prefixes.unshift('fis-um');
fis.cli.name = 'fis-um';
fis.set('project.ignore', ['/config.js']);
if (mode === 'replace' && config.config) {
config.config(fis);
return fis;
}
var $$config_str = "'" + JSON.stringify(config.$$config || config) + "'";
if (config.isSimple) {
fis.set('project.files', '*.html')
.match('*', {
deploy: [fis.plugin('skip-packed'), fis.plugin('local-deliver', {to: '../'})],
release: "/rd/$0"
})
.match('*.{html,js,css,less,htm,tpl}', {
parser: fis.plugin('replace',
{rules: [{search: /\/rs\//g, replace: "/"}, {search: '$$CONFIG', replace: $$config_str}]}
)
})
} else {
//一般模式部署规则
fis.set('project.files', '/*/**/*.{html,shtml}')
.hook('amd')
.match('*', {
deploy: [fis.plugin('skip-packed'), fis.plugin('local-deliver', {to: '../'})],
release: "/rd/$0"
})
//打包路径处理
.match('/(*)/({_,$})(**)', {
release: "/rd/$1/$3"
})
.match('/(*)/({_,$,})(*)/**.{js,htm,tpl}', {
packTo: '/$1/asset/$3.js'
})
.match('/(*)/({_,$,})(*)/**.{css,less}', {
packTo: '/$1/asset/$3.css'
})
.match('/3rd/**', {
packTo: false
})
//各类型资源处理
.match('*.{html,js,css,less,htm,tpl}', {
parser: fis.plugin('replace',
{rules: [{search: /\/rs\//g, replace: "/"}, {search: '$$CONFIG', replace: $$config_str}]}
)
})
.match('*.html', {
parser: fis.plugin('extract-inline', {libs: config.libs_html || config.libs}, "append")
})
.match('*.shtml', {
parser: fis.plugin('extract-inline', {libs: config.libs_shtml}, "append")
})
.match('*.js', {
isMod: true,
preprocessor: fis.plugin('js-require-css')
})
.match('{global,$lib}/**.js', {
isMod: false
})
.match('*.{htm,tpl}', {
isHtmlLike: true,
postprocessor: fis.plugin('tpl2js'),
rExt: '.js'
})
.match('*.less', {
parser: fis.plugin('less-2.x', null, "append"),
rExt: '.css'
})
.match('::package', {
postpackager: fis.plugin('loader', {
resourceType: 'amd', useInlineMap: false
})
});
}
// APP模式部署规则
if (config.isApp || config.isRelative) {
fis.set('project.files', '*.{html,xml}')
.hook('relative')
.match("*", {
relative: true,
deploy: [fis.plugin('skip-packed'), fis.plugin('local-deliver', {to: '../rd'})],
release: "/$0"
})
.match('/(*)/({_,$})(**)', {
release: "/$1/$3"
});
}
//上线部署模式
if (config.isMin) {
fis.set('project.md5Length', 6)
.set("settings.packager.map", {useTrack: false})
.match("*", {
domain: config.cdn,
useHash: true
})
.match('*.{css,less}', {
optimizer: fis.plugin('clean-css', {keepSpecialComments: 0})
})
.match('*.js', {
optimizer: fis.plugin('uglify-js', {comments: false})
})
.match('*.png', {
optimizer: fis.plugin('png-compressor')
})
.match('*.{html,xml}', {
useHash: false
});
}
if (mode === 'append' && config.config)
config.config(fis);
return fis;
};