-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuse.js
58 lines (46 loc) · 1.35 KB
/
fuse.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
const dev = process.argv[2] ? (process.argv[2].indexOf('development') !== -1) || (process.argv[2].indexOf('production') === -1) : true
const fs = require('fs-extra')
const {
FuseBox,
UglifyESPlugin
} = require('fuse-box')
const fuseBoxConfig = {
homeDir: 'src',
output: 'dist/js/$name.js',
plugins: [],
target: 'browser',
tsConfig: 'tsconfig.json',
experimentalFeatures: true
}
if (!dev) {
fuseBoxConfig.plugins.push(UglifyESPlugin())
}
const fuse = FuseBox.init(fuseBoxConfig)
const panel = fuse.bundle('panel')
.instructions('>panel.ts')
const content = fuse.bundle('content')
.instructions('>content.ts')
const background = fuse.bundle('background')
.instructions('>background.ts')
const popup = fuse.bundle('popup')
.instructions('>popup.ts')
if (dev) {
fs.watch('src/build/default_manifest.json', {}, _ => {
updateManifest()
})
panel.watch()
content.watch()
background.watch()
popup.watch()
}
browserPolyfill()
updateManifest()
fuse.run()
function updateManifest () {
fs.copySync('src/build/default_manifest.json', 'dist/manifest.json')
}
function browserPolyfill () {
if (!fs.pathExistsSync('dist/js/browser-polyfill.min.js')) {
fs.copySync('node_modules/webextension-polyfill/dist/browser-polyfill.min.js', 'dist/js/browser-polyfill.min.js')
}
}