-
Notifications
You must be signed in to change notification settings - Fork 0
/
fis-conf.js
175 lines (159 loc) · 3.53 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
// typescript register
require('ts-node/register');
const config = require('./config/config.default').default({nane:'eggjs'});
var prefix = `${config.static.prefix}`;
var public = './app/public';
var view = './app/view';
/* global fis */
// set the project root directory
fis.project.setProjectRoot(__dirname + '/app/web');
// project ignores
var ignores = fis.get('project.ignore');
ignores = ignores.concat([
'.git/**',
'.svn/**',
'**.md',
'**.log',
'**.*.lock',
'**.project',
'fis-conf.js',
'package.json',
'MIT-LICENSE'
]);
fis.set('project.ignore', ignores);
// settings js module
fis.hook('commonjs', {
extList: ['.js', '.jsx', '.es', '.ts', '.tsx']
})
fis.match('/{node_modules}/**.js', {
isMod: true,
useSameNameRequire: true,
url: `${prefix}$1`,
deploy: fis.plugin('local-deliver', {
to: public
})
});
fis.unhook('components')
fis.hook('node_modules')
// settings static resources
fis.match('(**).ts', {
parser: fis.plugin('typescript', {
// options
}),
id: `$1`,
rExt: '.js',
url: `${prefix}$0`,
isMod: true,
deploy: fis.plugin('local-deliver', {
to: public
})
});
fis.match('**.d.ts', {
release: false
}, true);
fis.match('**.js', {
useHash: false,
url: `${prefix}$0`,
isMod: true,
deploy: fis.plugin('local-deliver', {
to: public
})
});
fis.match("/widget/global/**.js", {
isMod: false
});
// scss compilation
fis.match('**.scss', {
// from .scss to .css
rExt: '.css',
parser: fis.plugin('node-sass'),
preprocessor: fis.plugin('autoprefixer', {
"browsers": ["Android >= 2.1", "iOS >= 4", "ie >= 8", "firefox >= 15"],
"cascade": true
}),
url: `${prefix}$0`,
deploy: fis.plugin('local-deliver', {
to: public
})
});
fis.match('**.{png,gif,svg,jpg,ico,swf}', {
useHash: false,
url: `${prefix}$0`,
deploy: fis.plugin('local-deliver', {
to: public
})
})
fis.match('**.html', {
useHash: false,
useMap: true,
deploy: fis.plugin('local-deliver', {
to: view
}),
})
// settings packager file
fis.match('/pkg/**', {
useHash: false,
url: `${prefix}$0`,
deploy: fis.plugin('local-deliver', {
to: public
})
})
fis.match('::packager', {
// analyze __RESOURCE_MAP__ structure to solve resource loading problem
postpackager: fis.plugin('loader', {
resourceType: 'commonjs',
// resource map embedded
useInlineMap: false
}),
packager: fis.plugin('map', {
// whether to write the file path before the merge into the comment
useTrack: false,
}),
spriter: fis.plugin('csssprites', {
layout: 'matrix',
margin: '15'
})
})
//--- prod ---
fis.media('prod')
.match('**.js', {
optimizer: fis.plugin('uglify-js', {
mangle: {
// variables that do not want to be uglify
expect: 'require,define,exports,module'
},
compress: {
// remove debugging information
drop_console: true
}
})
})
// compressed files are not processed
.match('**.min.js', {
optimizer: null
})
// html compression
.match('**.html', {
optimizer: fis.plugin('html-minifier')
})
// style compression
.match('*.{css,scss}', {
optimizer: fis.plugin('clean-css', {
compatibility: 'ie8',
// keep a rule for a newline
keepBreaks: false
})
})
// image compression
.match('*.png', {
optimizer: fis.plugin('png-compressor', {
removeComments: true,
removeEmptyElements: false,
})
});
// set pack
fis.media('prod').match('::packager', {
postpackager: fis.plugin('loader', {
allInOne: true
})
})