-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
70 lines (67 loc) · 2.2 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
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import swc from '@rollup/plugin-swc';
import dtsPlugin from 'rollup-plugin-dts';
const node = {
input: './src/index.js',
external: ['css-tree'],
output: [
{
file: './dist/ecsstree.cjs',
format: 'cjs',
exports: 'auto',
sourcemap: false,
},
{
file: './dist/ecsstree.js',
format: 'esm',
sourcemap: false,
},
],
plugins: [
json(),
swc(),
resolve({ preferBuiltins: false }),
],
};
// Automatically export type definitions from @types/css-tree
const dts = {
input: './ecsstree.d.ts',
output: [
{
file: 'dist/ecsstree.d.ts',
format: 'es',
// Add a banner to the top of the file
// Note: don't add it directly to the file, because it will be moved
// to the end of the file by Rollup, since it handles the imported
// module first
banner: [
'/*',
' * Automatically exported CSSTree type definitions. Since ECSSTree uses',
' * the exact same API as CSSTree, we can use the same type definitions.',
' *',
" * However, we can't use the @types/css-tree directly, because of a naming",
" * conflict with the actual CSSTree package. Our package is called '@adguard/ecss-tree',",
" * but the type definitions are written for 'css-tree'. Therefore, we need to",
' * export type definitions from @types/css-tree to this file at build time.',
' *',
' * Source: https://www.npmjs.com/package/@types/css-tree',
' */',
' ',
].join('\n'),
},
],
plugins: [
dtsPlugin({
// By default, this plugin excludes all external dependencies from the
// type definitions. We want to include them, so we set this option to
// true
respectExternal: true,
}),
],
};
// Export build configs for Rollup
export default [
node,
dts,
];