This repository has been archived by the owner on Feb 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
rollup.config.js
58 lines (57 loc) · 1.67 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
import typescript from 'rollup-plugin-typescript2';
import { terser } from 'rollup-plugin-terser';
import babel from 'rollup-plugin-babel';
import serve from 'rollup-plugin-serve';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
export default function (commandOptions) {
const distPath = commandOptions.watch ? 'examples/dist' : 'dist';
return [
{
input: 'src/scroll.ts',
output: {
format: 'esm',
file: `${distPath}/scroll.js`,
},
plugins: [typescript()],
watch: {
include: 'src/**',
},
},
{
input: `${distPath}/scroll.js`,
output: {
format: 'umd',
name: 'Scroll',
file: `${distPath}/scroll.common.js`,
},
plugins: [
resolve({ browser: true }),
commonjs(),
babel({
extensions: ['.js'],
}),
],
},
{
input: `${distPath}/scroll.js`,
output: {
format: 'esm',
file: `${distPath}/scroll.min.js`,
},
plugins: [
terser({
compress: true,
mangle: true,
}),
commandOptions.watch &&
serve({
open: true,
historyApiFallback: true,
contentBase: 'examples',
port: 9383,
}),
],
},
];
}