-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesbuild.js
66 lines (64 loc) · 1.87 KB
/
esbuild.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
const path = require('path');
const esbuild = require('esbuild');
const sassPlugin = require('esbuild-plugin-sass');
console.log("Starting watcher...");
esbuild.build({
entryPoints: ["website-theme/scss/blog-post/index.scss", "website-theme/scss/boilerplate/index.scss", "website-theme/ts/boilerplate.ts"],
bundle: true,
metafile: true,
color: true,
minify: true,
sourcemap: false,
splitting: false,
logLevel: "info",
format: 'esm',
platform: 'browser',
outdir: "website-theme/dist",
incremental: true,
watch: {
onRebuild(error, result) {
if (error) console.error('watch build failed:', error)
else console.log('watch build succeeded:'/*, esbuild.analyzeMetafileSync(result.metafile, {
verbose: false
})*/)
},
},
plugins: [
sassPlugin(
{
cache: true,
cssImports: false
},
),
{
name: "temp",
setup(build) {
build.onResolve({filter: /\.(ttf|webp)$/}, args => {
let absPath = require('path').resolve(args.resolveDir, args.path)
return {
path: absPath.split("WebstormProjects/hubspot-theme-boilerplate/")[1],
external: true,
}
})
}
},
{
name: 'perf',
setup(build) {
build.onStart(() => {
console.time('Time:')
})
build.onEnd((result) => {
console.timeEnd('Time:')
})
}
}
]
}).then(r => {
/*console.log("Build:", esbuild.analyzeMetafileSync(r.metafile, {
verbose: false
}))*/
console.log('watching...')
}).catch((err) => {
console.log(err)
})