-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
42 lines (37 loc) · 1.05 KB
/
index.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
import Parcel from '@parcel/core'
import config from '@parcel/config-default'
import AsyncObservable from '../utils/async-observable.ts'
export enum PARCEL_REPORTER_EVENT {
BUILD_START = 'buildStart',
BUILD_PROGRESS = 'buildProgress',
BUILD_SUCCESS = 'buildSuccess',
BUILD_FAILURE = 'buildFailure',
LOG = 'log'
}
export default (initialParcelOptions) =>
AsyncObservable(async observer => {
const parcel = new Parcel({
defaultConfig: {
...config,
filePath: require.resolve('@parcel/config-default')
},
entries: ['tests/unit/index_test.ts'],
targets: {
test: {
distDir: '.epk/dist/browser',
publicUrl: './'
// browsers: ['last 1 Chrome versions']
}
},
cacheDir: '.epk/parcel-cache',
mode: 'production',
sourceMaps: true,
minify: true,
scopeHoist: true
})
const { unsubscribe } = await parcel.watch((err, build) => {
if (err) observer.throw(err)
observer.next(build)
})
return () => unsubscribe()
})