-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.dev.mjs
More file actions
59 lines (53 loc) · 1.13 KB
/
esbuild.dev.mjs
File metadata and controls
59 lines (53 loc) · 1.13 KB
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
import * as esbuild from 'esbuild'
import { copy } from 'esbuild-plugin-copy'
import { sassPlugin } from 'esbuild-sass-plugin'
import server from 'esbuild-server'
let examplePlugin = {
name: 'example',
setup(build) {
build.onEnd(result => {
console.log(`${new Date().toLocaleTimeString('it-IT')}: build ended with ${result.errors.length} errors`)
})
},
}
// esbuild src/app.jsx --bundle --outfile=../priv/static/app.js --watch
let ctx = await esbuild.context({
entryPoints: ['src/app.jsx', 'css/app.sass'],
bundle: true,
sourcemap: 'inline',
outdir: './dist',
target: [
'esnext'
],
plugins: [
sassPlugin(),
examplePlugin,
copy({
resolveFrom: 'cwd',
assets: {
from: ['./images/*'],
to: ['./dist/images'],
},
}),
copy({
resolveFrom: 'cwd',
assets: {
from: ['./src/*.html'],
to: ['./dist'],
},
}),
],
})
await ctx.watch()
server.createServer(
{
bundle: false,
entryPoints: ['src/app.jsx']
},
{
static: 'dist',
port: 8000
}
)
.start()
console.log('Watching and listen on http://localhost:8000')