-
-
Notifications
You must be signed in to change notification settings - Fork 148
/
rollup.config.js
105 lines (98 loc) · 2.04 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
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import dts from 'rollup-plugin-dts';
// adds a header and calls initOnLoad() in the browser
function fix() {
return {
renderChunk(code) {
code = `/*!
* NetteForms - simple form validation.
*
* This file is part of the Nette Framework (https://nette.org)
* Copyright (c) 2004 David Grudl (https://davidgrudl.com)
*/
`
+ code;
code = code.replace('global.Nette = factory()', 'global.Nette?.noInit ? (global.Nette = factory()) : (global.Nette = factory()).initOnLoad()');
code = code.replace(/\/\*\*.*\* \*\//s, '');
return code;
},
};
}
function spaces2tabs() {
return {
renderChunk(code) {
return code.replaceAll(' ', '\t');
},
};
}
export default [
{ // TODO: consider the possibility of cutting off the UMD versions completely due to collision
input: 'src/assets/index.umd.ts',
output: [
{
format: 'umd',
name: 'Nette',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.umd.js',
generatedCode: 'es2015',
},
{
format: 'umd',
name: 'Nette',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.umd.min.js',
generatedCode: 'es2015',
plugins: [
terser(),
],
},
],
plugins: [
json(),
nodeResolve(),
typescript(),
fix(),
spaces2tabs(),
],
},
{
input: 'src/assets/index.esm.ts',
output: [
{
format: 'es',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.esm.js',
generatedCode: 'es2015',
},
{
format: 'es',
dir: 'src/assets/dist',
entryFileNames: 'nette-forms.esm.min.js',
generatedCode: 'es2015',
plugins: [
terser(),
],
},
],
plugins: [
json(),
nodeResolve(),
typescript(),
spaces2tabs(),
],
},
{
input: 'src/assets/index.esm.ts',
output: [{
file: 'src/assets/dist/nette-forms.d.ts',
format: 'es',
}],
plugins: [
dts(),
spaces2tabs(),
],
},
];