forked from tswaters/fireworks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
84 lines (80 loc) · 1.85 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import resolve from 'rollup-plugin-node-resolve'
import { terser } from 'rollup-plugin-terser'
import typescript from 'rollup-plugin-typescript'
import copy from 'rollup-plugin-copy'
import html from 'rollup-plugin-html2'
import serve from 'rollup-plugin-serve'
const isWatch = process.argv.includes('-w') || process.argv.includes('--watch')
const isProduction = process.env.NODE_ENV !== 'development'
const distFiles = [
'fireworks.d.ts',
'package.json',
'package-lock.json',
'LICENSE',
'README.MD',
'RELEASE.MD',
'CHANGES.MD',
'bower.json',
]
const config = ({
format,
file,
minify,
useServer = false,
useHtml = false,
}) => ({
input: './ts/fireworks.ts',
output: {
name: 'Fireworks',
file,
format,
amd: { id: 'Fireworks' },
sourcemap: !isProduction,
},
plugins: [
typescript({ target: format === 'umd' ? 'es3' : 'es6' }),
copy({
targets: distFiles.map((file) => ({ src: file, dest: './dist/' })),
}),
useHtml &&
html({
template: './html/index.html',
fileName: 'index.html',
inject: 'head',
}),
resolve({
extensions: ['.js', '.mjs'],
}),
minify && terser(),
useServer &&
serve({
port: 8001,
host: '0.0.0.0',
contentBase: ['dist'],
open: false,
wait: 500,
}),
],
})
export default [
config({
format: 'umd',
file: './dist/fireworks.js',
minify: false,
useServer: !isProduction && isWatch,
useHtml: !isProduction,
}),
config({
format: 'umd',
file: './dist/fireworks.min.js',
minify: true,
}),
config({
format: 'umd',
file: './gh-pages/fireworks.min.js',
minify: true,
useHtml: true,
}),
config({ format: 'module', file: './dist/fireworks.mjs', minify: false }),
config({ format: 'cjs', file: './dist/fireworks.node.js', minify: false }),
]