forked from FuelRats/api.fuelrats.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
53 lines (45 loc) · 1.17 KB
/
rollup.config.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
/* eslint-disable no-console */
import { babel } from '@rollup/plugin-babel'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import fs from 'fs'
import gitrev from 'git-rev-promises'
import autoExternal from 'rollup-plugin-auto-external'
import pkg from './package.json'
Promise.all([
gitrev.long(),
gitrev.branch(),
gitrev.tags(),
gitrev.date(),
]).then(([hash, branch, tags, date]) => {
const buildJson = JSON.stringify({
version: pkg.version,
hash,
branch,
tags,
date,
})
fs.writeFile('build.json', buildJson, 'utf8', () => {
console.info('Build information saved')
})
})
const defineEntry = (input, outputDir) => {
return {
input,
output: {
dir: outputDir,
format: 'esm',
entryFileNames: '[name].mjs',
sourcemap: true,
},
external: ['nanoid/async'],
preserveModules: true,
plugins: [autoExternal(), json(), resolve(), babel({ babelHelpers: 'bundled' })],
}
}
const config = [
defineEntry('src/index.mjs', 'dist'),
defineEntry('src/workers/certificate.mjs', 'dist/workers'),
defineEntry('src/workers/image.mjs', 'dist/workers'),
]
export default config