-
Notifications
You must be signed in to change notification settings - Fork 224
Expand file tree
/
Copy pathrollup.config.js
More file actions
60 lines (53 loc) · 1.61 KB
/
rollup.config.js
File metadata and controls
60 lines (53 loc) · 1.61 KB
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
59
60
import terser from '@rollup/plugin-terser'
import { readFileSync, writeFileSync, copyFileSync } from 'fs'
const pkg = JSON.parse(readFileSync('./package.json', 'utf8'))
const currentYear = new Date().getFullYear()
const buildDate = new Date().toISOString().replace('T', ' ').substring(0, 16)
const banner = ` // ----------------------------------------------------------------------------
// ${pkg.description}
// v${pkg.version} - Built ${buildDate}
// Licensed under the MIT license.
// http://buzz.jaysalvat.com/
// ----------------------------------------------------------------------------
// Copyright (C) 2010-${currentYear} Jay Salvat
// http://jaysalvat.com/
// ----------------------------------------------------------------------------
`
// Generate metadata files
const metadata = {
date: buildDate + ':00',
version: pkg.version
}
writeFileSync('dist/metadata.json', JSON.stringify(metadata, null, 2))
writeFileSync('dist/metadata.js', `__metadata(${JSON.stringify(metadata, null, 2)})`)
// Copy TypeScript definitions
copyFileSync('src/buzz.d.ts', 'dist/buzz.d.ts')
export default [
// ES Module build (for modern imports)
{
input: 'src/buzz.js',
output: {
file: 'dist/buzz.js',
format: 'es',
banner: banner
}
},
// UMD build (for CDN/legacy usage, minified)
{
input: 'src/buzz.js',
output: {
file: 'dist/buzz.min.js',
format: 'umd',
name: 'buzz',
banner: banner.split('\n').map(line => line.trim()).join('\n'),
sourcemap: true
},
plugins: [
terser({
format: {
comments: /^!/
}
})
]
}
]