-
Notifications
You must be signed in to change notification settings - Fork 54
/
rollup.config.js
123 lines (119 loc) · 2.82 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/* eslint-env node */
import commonJs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import cleanup from 'rollup-plugin-cleanup';
import pkg from './package.json';
const input = 'src/index.ts';
const external = Object.keys( pkg.peerDependencies || {} );
const banner = `/**
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md.
*/`;
export default [
// Creates `umd` build that can be directly consumed via <script /> tag (development mode).
// Setting `NODE_ENV` value to `development` enables dev utils such as prop-types.
{
input,
external,
output: {
banner,
format: 'umd',
file: 'dist/index.umd.development.js',
name: 'CKEditor4React',
globals: {
react: 'React'
}
},
plugins: [
typescript(),
nodeResolve(),
commonJs(),
replace( {
preventAssignment: true,
values: {
'process.env.NODE_ENV': '"development"'
}
} ),
cleanupPlugin()
]
},
// Creates `umd` build that can be directly consumed via <script /> tag (production mode).
// Setting `NODE_ENV` value to `production` disables dev utils.
{
input,
external,
output: {
banner,
format: 'umd',
file: 'dist/index.umd.production.min.js',
name: 'CKEditor4React',
globals: {
react: 'React'
}
},
plugins: [
typescript(),
nodeResolve(),
commonJs(),
replace( {
preventAssignment: true,
values: {
'process.env.NODE_ENV': '"production"'
}
} ),
cleanupPlugin(),
terser()
]
},
// Creates `cjs` build that can be further optimized downstream.
{
input,
external: external.concat( [
'ckeditor4-integrations-common',
'prop-types'
] ),
output: {
banner,
format: 'cjs',
file: 'dist/index.cjs.js'
},
plugins: [ typescript(), cleanupPlugin() ]
},
// Creates `esm` build that can be further optimized downstream.
{
input,
external: external.concat( [
'ckeditor4-integrations-common',
'prop-types'
] ),
output: {
banner,
format: 'esm',
file: 'dist/index.esm.js'
},
plugins: [ typescript(), cleanupPlugin() ]
}
];
/**
* Prepares `cleanup` plugin to remove unnecessary 3rd party licenses, e.g.
*
* - `tslib` 0BSD license (3rd parties are not required to include it)
* - CKSource licenses from dependencies
*
* https://github.com/microsoft/tslib/blob/master/LICENSE.txt
* https://github.com/microsoft/tslib/issues/47
*
* @returns {Plugin} configured plugin
*/
function cleanupPlugin() {
return cleanup( {
extensions: [ 'ts', 'tsx', 'js' ],
comments: [
/Copyright (c) Microsoft Corporation./,
/@license Copyright (c) 2003-2024, CKSource Holding sp. z o.o./
]
} );
}