-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparcel.bundler.js
40 lines (35 loc) · 1 KB
/
parcel.bundler.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
import path from 'path'
import Bundler from 'parcel-bundler'
import chalk from 'chalk'
import { fork } from 'child_process'
const PORT = 1666
const entryPath = path.resolve(__dirname, 'src', 'index.html')
const bundler = new Bundler(entryPath, {
outDir: path.resolve(__dirname, 'build'),
outFile: 'index.html',
watch: true,
cache: true,
cacheDir: path.resolve(__dirname, '.cache'),
target: 'browser',
sourceMaps: true,
hmrPort: 0
})
bundler.serve(PORT)
const firebaseListeners = fork(path.resolve(__dirname, 'developer', 'developer.js'))
/* ================= */
/* === LISTENERS === */
/* ================= */
bundler.on('bundled', (b) => {
// process.send({type: 'bundled'})
// console.log(chalk.green(`Built`))
})
bundler.on('buildEnd', (b) => {
// process.send({type: 'buildEnd'})
// console.log(chalk.green(`Rebuilt`))
})
bundler.on('buildError', (err) => {
// process.send({type: 'buildEnd'})
console.log(chalk.red(`Build error`))
console.log('')
console.log(chalk.red(err.message))
})