-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
73 lines (69 loc) · 1.71 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
import serve from 'rollup-plugin-serve'
import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import banner from 'rollup-plugin-banner'
import typescript from 'rollup-plugin-typescript2'
import { babel } from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
const FORMAT = process.env.FORMAT
const IS_TEST_ENV = process.env.NODE_ENV === 'test'
const DIST_FILE_NAME = 'index'
const TEST_DIR = '__test__'
const DIST_DIR = './'
const UMD_NAME = 'Gifff'
const plugins = [
resolve({ jsnext: true, preferBuiltins: true, browser: true }),
commonjs(),
typescript({
tsconfig: IS_TEST_ENV ? 'tsconfig.test.json' : 'tsconfig.json'
}),
babel({
exclude: /node_modules/,
babelrc: false,
babelHelpers: 'runtime',
presets: [
'@babel/preset-env'
],
plugins: [
[
'@babel/plugin-transform-runtime',
{ targets: '> 0.25%, not dead' }
]
]
}),
IS_TEST_ENV && serve(TEST_DIR),
IS_TEST_ENV && livereload({
watch: TEST_DIR,
verbose: false
}),
!IS_TEST_ENV && terser({
output: {
comments: false
}
}),
!IS_TEST_ENV && banner('https://github.com/lijialiang/gifff v<%= pkg.version %>')
]
const config = [
{
input: './src/wasm.ts',
output: {
file: IS_TEST_ENV ? `${TEST_DIR}/wasm.js` : `${DIST_DIR}/wasm.js`,
format: 'umd',
name: UMD_NAME,
sourcemap: false
},
plugins
},
{
input: './src/canvas.ts',
output: {
file: IS_TEST_ENV ? `${TEST_DIR}/canvas.js` : `${DIST_DIR}/canvas.js`,
format: 'umd',
name: UMD_NAME,
sourcemap: false
},
plugins
}
]
export default config