-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
56 lines (51 loc) · 1.4 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
53
54
55
56
import {terser} from "rollup-plugin-terser"
import pkg from "./package.json"
import fs from "node:fs"
const production = (process.env.MODE === 'production')
const banner = `
/*!
* Farbe v${pkg.version} - Color manipulation library
* Copyright ${new Date().getFullYear()} by Serhii Pimenov
* Licensed under MIT
!*/
`
let txt = fs.readFileSync(`src/index.js`, 'utf8')
txt = txt.replace(/version = ".+"/g, `version = "${pkg.version}"`)
txt = txt.replace(/build_time = ".+"/g, `build_time = "${new Date().toLocaleString()}"`)
fs.writeFileSync(`src/index.js`, txt, { encoding: 'utf8', flag: 'w+' })
export default [
{
input: './src/browser.js',
watch: { clearScreen: false },
output: {
file: './lib/farbe.js',
format: 'iife',
sourcemap: false,
banner,
plugins: [
production && terser({
keep_classnames: true,
keep_fnames: true,
})
],
}
},
{
input: './src/index.js',
watch: { clearScreen: false },
output: {
file: './dist/farbe.es.js',
format: 'es',
banner,
}
},
{
input: './src/index.js',
watch: { clearScreen: false },
output: {
file: './dist/farbe.cjs.js',
format: 'cjs',
banner,
}
},
];