This repository has been archived by the owner on Oct 10, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
fis-conf.js
223 lines (187 loc) · 4.57 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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
var execSync = require('child_process').execSync;
var pkg = require('./package.json');
var branch = execSync('git rev-parse --abbrev-ref HEAD').toString('utf8').replace(/\n*$/, '');
var MOD_CACHE = process.env.CACHE;
var DEBUG = process.env.DEBUG;
// MOD_CACHE, whether enable mod.js localStorage cache
if(MOD_CACHE == 'false'){
MOD_CACHE = false;
}else{
MOD_CACHE = true;
}
// DEBUG, whether enable console & vConsole
if(DEBUG == 'true'){
DEBUG = true;
}else{
DEBUG = false;
}
var autoprefixerOption = {
browsers: ['> 1%']
};
var typescriptCompilerOption = {
sourceMap: true,
baseUrl: 'src',
noEmitHelpers: true,
importHelpers: true,
target: 1 // target: ES5
};
/// ======================== common settings ========================
if(process.platform === 'linux'){
fis.set('project.watch.usePolling', true);
}
fis.set('project.files', ['src/**']);
fis.set('project.ignore', fis.get('project.ignore').concat([
'**.md',
'**.json'
]));
fis.set('project.md5Length', 8);
fis.set('project.fileType.text', 'vue');
fis.hook('commonjs', {
baseUrl: 'src',
extList: ['.ts', '.js', '.vue'],
paths: {
'vue': '/node_modules/vue/dist/vue.js'
}
});
/// ======================== develop environment ========================
// 发布地址 => development
fis.match('/src/(**)', {
release: '/dist/$1',
url: (branch === 'gh-pages' ? '/fis3-typescript-vue-hackernews-2.0' : '') + '/dist/$1'
})
.match('/src/(**).vue', {
id: '$1',
isMod: true,
parser: [
fis.plugin('vue-component', {
runtimeOnly: true,
extractCSS: false,
cssScopedFlag: null
})
],
rExt: '.js'
})
.match('/src/**.{css,vue:css,vue:stylus}', {
postprocessor: fis.plugin('autoprefixer', autoprefixerOption)
})
.match('/src/**.vue:stylus', {
parser: fis.plugin('stylus')
})
.match('/src/(**).{js,ts,vue:js}', {
id: '$1',
isMod: true,
parser: fis.plugin('typescript', typescriptCompilerOption),
rExt: '.js'
})
.match('/src/**.d.ts', {
release: false
}, true)
// no not wrap plugin files
.match('/src/plugins/**.js', {
isMod: false
})
.match('/(node_modules/**)', {
release: '/dist/$1',
url: '$1'
})
.match('/(node_modules/**.js)', {
isMod: true,
useSameNameRequire: false
})
.match('/node_modules/**.map', {
release: false
})
.match('::package', {
postpackager: fis.plugin('loader', {
resourceType: 'mod',
useInlineMap: true // 资源映射表内嵌
})
});
/// ======================== production envionment ========================
fis
.media('prod')
/// do not release test related files
.match('/src/**.spec.{js,ts}', {
release: false
})
/// === packTo 配置, 将一些文件打包合并在一起
// node_modules 库, 只 packTo 部分文件, 有的文件不是全局依赖还是按需加载
.match('/(node_modules/{' + require('./src/runtimes/packages.json').join(',') + '}/**.{js,ts})', {
packTo: '/src/runtimes/packages.js'
})
// init 初始化文件
.match('/src/{boot,app}.{js,ts,vue}', {
packTo: '/src/runtimes/init.js'
})
// 全局 runtimes 文件
.match('/src/runtimes/**.{js,ts,vue}', {
packTo: '/src/runtimes/init.js'
})
// 各个页面自用的文件, 打包成一个文件, 减少http请求
.match('/src/views/(*)/**.{js,ts,vue}', {
packTo: '/src/views/$1-pack.js'
})
// 使用hash
.match('::text', {
useHash: true
})
.match('::image', {
useHash: true
})
/// optimize
.match('/{src,node_modules}/**.{ts,js,vue}', {
optimizer: fis.plugin('uglify-js', {
compress: {
warnings: false,
drop_console: !DEBUG,
dead_code: true,
global_defs: {
__MOD_CACHE: MOD_CACHE,
__DEBUG: DEBUG
}
},
output: {
ascii_only: true
},
comments: false,
mangle: true
})
})
.match('/src/**.{css,vue:css,vue:stylus}', {
release: false,
optimizer: fis.plugin('clean-css')
})
.match('/src/**.{html,vue:html}', {
release: false,
optimizer: fis.plugin('dfy-html-minifier', {
removeComments: true,
collapseWhitespace: true
})
})
.match('/src/index.html', {
useHash: false,
release: '/dist/index.html',
optimizer: fis.plugin('dfy-html-minifier', {
removeComments: false,
collapseWhitespace: true
})
}, true)
// all in one pack
.match('::package', {
postpackager: fis.plugin('loader', {
resourceType: 'mod',
resourcemapWhitespace: 0,
useInlineMap: true // 资源映射表内嵌
})
})
// 过滤掉已经被打包的资源
.match('**', {
deploy: [
fis.plugin('skip-packed'),
fis.plugin('local-deliver')
]
})
/// ======================== fis-hook-node_modules ========================
// 禁用components
fis.unhook('components');
fis.hook('node_modules');