Skip to content

Commit 98765fa

Browse files
committed
improve CI
1 parent 80e68c8 commit 98765fa

14 files changed

+111304
-994
lines changed

build.js

+135-62
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { build } from 'esbuild';
1+
import { build, context } from 'esbuild';
22
import { lessLoader } from "esbuild-plugin-less";
33
import progress from "@olton/esbuild-plugin-progress";
44
import autoprefixer from "@olton/esbuild-plugin-autoprefixer";
@@ -24,67 +24,140 @@ const banner = `
2424
*/
2525
`
2626

27-
await build({
28-
entryPoints: ['./source/default.js'],
29-
outfile: './lib/metro.js',
30-
bundle: true,
31-
minify: production,
32-
sourcemap: false,
33-
banner: {
34-
js: banner
35-
},
36-
plugins: [
37-
progress({
38-
text: 'Building Metro UI...',
39-
succeedText: `Metro UI built successfully in %s ms!`
40-
}),
41-
lessLoader(),
42-
autoprefixer(),
43-
replace({
44-
'__BUILD_TIME__': new Date().toLocaleString(),
45-
'__VERSION__': version,
46-
})
47-
],
48-
})
27+
if (production) {
28+
await build({
29+
entryPoints: ['./source/default.js'],
30+
outfile: './lib/metro.js',
31+
bundle: true,
32+
minify: production,
33+
sourcemap: false,
34+
banner: {
35+
js: banner
36+
},
37+
plugins: [
38+
progress({
39+
text: 'Building Metro UI...',
40+
succeedText: `Metro UI built successfully in %s ms!`
41+
}),
42+
lessLoader(),
43+
autoprefixer(),
44+
replace({
45+
'__BUILD_TIME__': new Date().toLocaleString(),
46+
'__VERSION__': version,
47+
})
48+
],
49+
})
4950

50-
await build({
51-
entryPoints: ['./source/index.js'],
52-
outfile: './lib/metro.all.js',
53-
bundle: true,
54-
minify: production,
55-
sourcemap: false,
56-
banner: {
57-
js: banner
58-
},
59-
plugins: [
60-
progress({
61-
text: 'Building Metro UI with icons...',
62-
succeedText: 'Metro UI with icons built successfully in %s ms!'
63-
}),
64-
lessLoader(),
65-
autoprefixer(),
66-
replace({
67-
'__BUILD_TIME__': new Date().toLocaleString(),
68-
'__VERSION__': version,
69-
})
70-
],
71-
})
51+
await build({
52+
entryPoints: ['./source/index.js'],
53+
outfile: './lib/metro.all.js',
54+
bundle: true,
55+
minify: production,
56+
sourcemap: false,
57+
banner: {
58+
js: banner
59+
},
60+
plugins: [
61+
progress({
62+
text: 'Building Metro UI with icons...',
63+
succeedText: 'Metro UI with icons built successfully in %s ms!'
64+
}),
65+
lessLoader(),
66+
autoprefixer(),
67+
replace({
68+
'__BUILD_TIME__': new Date().toLocaleString(),
69+
'__VERSION__': version,
70+
})
71+
],
72+
})
73+
74+
await build({
75+
entryPoints: ['./source/icons.js'],
76+
outfile: './lib/icons.js',
77+
bundle: true,
78+
minify: production,
79+
sourcemap: false,
80+
plugins: [
81+
progress({
82+
text: 'Building Metro UI icons...',
83+
succeedText: 'Metro UI icons built successfully in %s ms!'
84+
}),
85+
lessLoader(),
86+
unlink({
87+
files: ['./lib/icons.js']
88+
})
89+
],
90+
})
91+
} else {
92+
let ctxLib = await context({
93+
entryPoints: ['./source/default.js'],
94+
outfile: './lib/metro.js',
95+
bundle: true,
96+
minify: false,
97+
sourcemap: true,
98+
banner: {
99+
js: banner
100+
},
101+
plugins: [
102+
progress({
103+
text: 'Building Metro UI...',
104+
succeedText: 'Library compiled in %s ms! Watching for changes...'
105+
}),
106+
lessLoader(),
107+
autoprefixer(),
108+
replace({
109+
'__BUILD_TIME__': new Date().toLocaleString(),
110+
'__VERSION__': pkg.version,
111+
})
112+
],
113+
})
114+
115+
let ctxAll = await context({
116+
entryPoints: ['./source/index.js'],
117+
outfile: './lib/metro.all.js',
118+
bundle: true,
119+
minify: false,
120+
sourcemap: true,
121+
banner: {
122+
js: banner
123+
},
124+
plugins: [
125+
progress({
126+
text: 'Building Metro UI...',
127+
succeedText: 'Library compiled in %s ms! Watching for changes...'
128+
}),
129+
lessLoader(),
130+
autoprefixer(),
131+
replace({
132+
'__BUILD_TIME__': new Date().toLocaleString(),
133+
'__VERSION__': pkg.version,
134+
})
135+
],
136+
})
137+
138+
let ctxIcons = await context({
139+
entryPoints: ['./source/icons.js'],
140+
outfile: './lib/icons.js',
141+
bundle: true,
142+
minify: production,
143+
sourcemap: false,
144+
plugins: [
145+
progress({
146+
text: 'Building Metro UI icons...',
147+
succeedText: 'Icons compiled in %s ms! Watching for changes...'
148+
}),
149+
lessLoader(),
150+
unlink({
151+
files: ['./lib/icons.js']
152+
})
153+
],
154+
})
155+
156+
await Promise.all([
157+
await ctxLib.watch(),
158+
await ctxIcons.watch(),
159+
await ctxAll.watch(),
160+
])
161+
}
72162

73-
await build({
74-
entryPoints: ['./source/icons.js'],
75-
outfile: './lib/icons.js',
76-
bundle: true,
77-
minify: production,
78-
sourcemap: false,
79-
plugins: [
80-
progress({
81-
text: 'Building Metro UI icons...',
82-
succeedText: 'Metro UI icons built successfully in %s ms!'
83-
}),
84-
lessLoader(),
85-
unlink({
86-
files: ['./lib/icons.js']
87-
})
88-
],
89-
})
90163

commit.cmd

-2
This file was deleted.

delete-tag.bat

-1
This file was deleted.

deploy.js

-49
This file was deleted.

0 commit comments

Comments
 (0)