forked from lukeed/fly-kit-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flyfile.js
97 lines (83 loc) · 2.18 KB
/
flyfile.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
'use strict';
const bs = require('browser-sync');
const reload = () => isWatch && isServer && bs.reload();
let isWatch = 0;
let isServer = 0;
const tar = 'dist';
const rel = 'release';
const node = 'node_modules';
const bower = 'bower_components';
const src = {
css: 'src/styles/**/*.sass',
js: 'src/scripts/**/*.js',
img: 'src/images/**/*.*',
copy: [
'src/*.html',
'src/extras/**.*'
],
vendor: [
// javascript vendors to be merged
]
};
export default async function (fly) {
isWatch = 1;
await fly.clear([tar, rel]).start('build');
await fly.watch(src.js, 'scripts');
await fly.watch(src.vendor, 'vendor');
await fly.watch(src.copy, 'copies');
await fly.watch(src.img, 'images');
await fly.watch(src.css, 'styles');
await fly.start('serve');
}
export async function build(fly) {
await fly.clear([tar, rel]);
await fly.parallel(['copies', 'images', 'vendor', 'scripts', 'styles']);
await fly.start('uglify');
}
export async function release(fly) {
await fly.source(`${tar}/**/*`)
.rev({ignores: ['.html', '.png', 'jpg', '.jpeg', '.svg', '.ico', '.gif', '.json', '.webapp', '.txt']})
.revManifest({dest: rel, trim: tar}).revReplace().target(rel);
await fly.source(`${rel}/*.html`).htmlmin().target(rel);
}
export async function scripts(fly, o) {
await fly.source(o.src || src.js).xo().browserify({
entries: 'src/scripts/app.js'
}).target(`${tar}/js`);
reload();
}
export async function vendor(fly) {
await fly.source(src.vendor).concat('vendor.js').target(`${tar}/js`);
reload();
}
export async function copies(fly, o) {
await fly.source(o.src || src.copy).target(tar);
reload();
}
export async function images(fly, o) {
await fly.source(o.src || src.img).target(`${tar}/img`);
reload();
}
export async function styles(fly) {
await fly.source('src/styles/app.sass').sass({
outputStyle: 'compressed',
includePaths: [bower]
}).autoprefixer().target(`${tar}/css`);
reload();
}
export async function uglify(fly) {
await fly.source(`${tar}/js/*.js`).uglify({
compress: {
conditionals: 1,
drop_console: 1,
comparisons: 1,
join_vars: 1,
booleans: 1,
loops: 1
}
}).target(`${tar}/js`);
}
export async function serve(fly) {
isServer = 1;
bs({server: tar});
}