-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_for_chrome.js
38 lines (34 loc) · 1.06 KB
/
build_for_chrome.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
// Vite can't build multiple targetsa as self-contained apps, so we need to build for each target separately.
import { build } from 'vite'
import config from './vite.config.js'
import fs from 'fs-extra'
console.log('Building for Chrome...')
// Remove dist folder
fs.removeSync('./dist')
for (let input of Object.keys(config.build.rollupOptions.input)) {
console.log(`Building ${input}...`)
const inputConfig = {
...config,
build: {
...config.build,
emptyOutDir: false,
rollupOptions: {
...config.build.rollupOptions,
input: {
[input]: config.build.rollupOptions.input[input]
},
}
}
}
console.log(inputConfig.build.rollupOptions.input)
await build({
configFile: false,
root: './',
...inputConfig
})
}
console.log('Copying static files...')
// Copy manifest.json and assets to dist
// Using node.js
fs.copySync('./manifest.json', './dist/manifest.json')
fs.copySync('./assets', './dist/assets')