-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfis-conf.js
128 lines (121 loc) · 2.9 KB
/
fis-conf.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// fis dev
fis
.set('project.ignore', [
'node_modules/**',
'.idea/**',
'.git/**',
'fis-conf.js'
])
.hook('relative')
.match('**', {
relative: true,
useHash: false
})
.match('/components/**.js', {
isMod: true,
release: '$0',
domain: '.'
})
.match('/src/(**)', {
release: '$1'
})
.match('/src/js/**.js', {
parser: fis.plugin('es6-babel', {
optional: ["es7.classProperties"],
blacklist: ["useStrict"]
}),
isMod: true,
rExt: '.js',
domain: '.'
})
.hook('amd', {
packages: [
{
name: 'components',
location: '/src/js/components',
main: 'index.js'
}
]
})
.match('::package', {
// npm install [-g] fis3-postpackager-loader
// 分析 __RESOURCE_MAP__ 结构,来解决资源加载问题
postpackager: fis.plugin('loader', {
resourceType: 'amd',
useInlineMap: true // 资源映射表内嵌
})
})
.match('**.less', {
parser: fis.plugin('less'), //启用fis-parser-less插件
rExt: '.css',
postprocessor: fis.plugin('autoprefixer', {
browsers: [
"last 4 versions"
]
})
});
var prod = fisMedia = function(fisMedia) {
return fisMedia
.match('::package', {
// 关于打包配置,请参考:https://github.com/fex-team/fis3-packager-deps-pack
packager: fis.plugin('deps-pack', {
// 框架css
'/pkg/boot.css': [
//'/src/css/**'
],
// 业务CSS
'/pkg/app.css': [
'/src/css/**'
],
// 框架JS
'/pkg/boot.js': [
'/components/angular/**.js',
//'/components/react/react.js',
//'/components/react-dom/react-dom.js',
//'/components/ngReact/ngReact.js'
],
// 插件和库js
'/pkg/lib.js': [
'/components/jquery/**.js',
'/components/angular-ui-bootstrap/**.js',
'/components/angular-ui-router/**.js'
],
// 业务逻辑打包,如果需要,在这里单独配置
'/pkg/app.js': [
'/src/js/**.js'
]
})
})
.match('*.{js,jsx,es6}', {
optimizer: fis.plugin('uglify-js')
})
.match('*.{css,less}', {
optimizer: fis.plugin('clean-css'),
})
.match('*.png', {
optimizer: fis.plugin('png-compressor')
})
.match('*.{less,css,js}', {
useHash: true
})
.match('::image', {
useHash: true
})
};
prod(fis.media('prod'));
var DEPLOY_TO = '../dist';
prod(fis.media('deploy'))
.match('**', {
deploy: [
fis.plugin('local-deliver', {
to: DEPLOY_TO
}),
function() {
//打包好的替换相对路径
var rootHtmlPath = DEPLOY_TO + "/index.html";
var content = new fis.file(rootHtmlPath).getContent();
content = content.replace(/"\/pkg/g, "\"./pkg");
fis.util.write(rootHtmlPath, content);
}
]}
)