-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
88 lines (87 loc) · 2.39 KB
/
rollup.config.mjs
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
85
86
87
88
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import copy from 'rollup-plugin-copy';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import postcss from 'rollup-plugin-postcss';
import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
// eslint-disable-next-line import/no-default-export
export default [
// Outputs a javascript bundle for our components
{
input: 'src/index.tsx',
output: [
{
dir: 'dist/cjs',
format: 'cjs',
sourcemap: true
},
{
dir: 'dist/esm',
format: 'esm',
sourcemap: true
}
],
external: ['util'],
plugins: [
// Copy the original postcss files so the user can choose to use those if wanted
copy({
targets: [{ src: ['src/index.css', 'src/components*', '!**/*.{tsx, ts, jsx, js}'], dest: 'dist/postcss' }]
}),
json(),
peerDepsExternal(),
resolve(),
commonjs(),
// Utilize a specific tsconfig only for building
typescript({ clean: true, useTsconfigDeclarationDir: true, tsconfig: 'tsconfig.build.json' }),
postcss()
]
},
// Output a general non minified index.css
{
input: 'src/index.css',
output: [
{
file: 'dist/index.css',
format: 'es'
}
],
// Extract the css in a file
plugins: [postcss({ extract: true })],
/**
* Removes the "overwrites a previously emitted file of the same name." warn
* Because we actually want to output the css
*
* @param warning the warning object
* @param warn the warn callback
*/
onwarn(warning, warn) {
if (warning.code === 'FILE_NAME_CONFLICT') return;
warn(warning);
}
},
// Output a general minified index.min.css
{
input: 'src/index.css',
output: [
{
file: 'dist/index.min.css',
format: 'es'
}
],
// Turn on mification
// Extract the css in a file
plugins: [postcss({ minimize: true, extract: true })],
/**
* Removes the "overwrites a previously emitted file of the same name." warn
* Because we actually want to output the css
*
* @param warning the warning object
* @param warn the warn callback
*/
onwarn(warning, warn) {
if (warning.code === 'FILE_NAME_CONFLICT') return;
warn(warning);
}
}
];