generated from JavaScriptPlayground/Template-SolidJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.config.ts
78 lines (66 loc) · 1.89 KB
/
build.config.ts
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
/// <reference lib="deno.ns" />
import * as esbuild from 'https://deno.land/x/[email protected]/mod.js';
import sassPlugin from 'https://deno.land/x/[email protected]/mod.ts';
import { bold } from 'https://deno.land/[email protected]/fmt/colors.ts';
import { parseArgs } from 'https://deno.land/[email protected]/cli/parse_args.ts';
const args = parseArgs<{
watch: boolean | undefined;
develope: boolean | undefined;
}>(Deno.args);
const HTMLConfig: esbuild.BuildOptions = {
allowOverwrite: true,
logLevel: 'info',
color: true,
outdir: './dist',
loader: {
'.html': 'copy',
},
entryPoints: [
'./src/**/index.html',
]
};
const SASSConfig: esbuild.BuildOptions = {
allowOverwrite: true,
logLevel: 'info',
legalComments: args.develope ? 'inline' : 'none',
color: true,
minify: !args.develope ?? true,
outdir: './dist',
entryNames: '[dir]/bundle.min',
entryPoints: [
'./src/**/index.scss',
],
plugins: [
sassPlugin()
],
};
const TSConfig: esbuild.BuildOptions = {
tsconfig: './deno.json',
allowOverwrite: true,
logLevel: 'info',
legalComments: args.develope ? 'inline' : 'none',
color: true,
bundle: true,
minify: !args.develope ?? true,
target: 'ES6',
format: 'esm',
outdir: './dist',
entryNames: '[dir]/bundle.min',
entryPoints: [
'./src/**/index.ts'
],
};
if (!args.watch) {
console.log(bold('Coping HTML files...'));
await esbuild.build(HTMLConfig);
console.log(bold('Transpiling & Bundling SCSS files...'));
await esbuild.build(SASSConfig);
console.log(bold('Transpiling & Bundling TypeScript files...'));
await esbuild.build(TSConfig);
console.log(bold('Build process finished.'));
esbuild.stop();
} else {
await esbuild.context(HTMLConfig).then((context) => context.watch());
await esbuild.context(SASSConfig).then((context) => context.watch());
await esbuild.context(TSConfig).then((context) => context.watch());
}