-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
rollup.modules.config.js
75 lines (69 loc) · 1.98 KB
/
rollup.modules.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
import { files, cultures, messages, addKendoVersion, baseOptions, externals, removeBundle, root } from './rollup.config';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import polyfill from 'rollup-plugin-polyfill';
export function fixJQueryImport() {
return {
name: 'transform-fix-jquery-import',
renderChunk(code) {
code = code
.replace(/import 'jquery';/gm, 'import jQuery from "jquery";')
.replace(/require\('jquery'\)/gm, 'const jQuery = require("jquery");');
return {
code: code
};
}
};
}
/**
* @type {import('rollup').RollupOptions}
*/
const resourcesConfig = (name, options = {}) => ({
input: `${root}/${name}`,
output: [{
format: "esm",
dir: `./dist/esm/${options.dir}`,
sourcemap: false,
...baseOptions
},{
format: "cjs",
dir: `./dist/cjs/${options.dir}`,
sourcemap: false,
...baseOptions
}],
external: ['../kendo.core.js'],
treeshake: false,
plugins: [
addKendoVersion(),
polyfill(['../kendo.core.js'])
]
});
// rollup.config.js
/**
* @type {import('rollup').RollupOptions}
*/
const configMap = (name) => ({
input: `${root}/${name}`,
output: [{
format: 'esm',
dir: './dist/esm',
sourcemap: false,
...baseOptions
}, {
format: 'cjs',
dir: './dist/cjs',
sourcemap: false,
exports: 'auto',
...baseOptions
}],
external: externals.filter(removeBundle(name)),
treeshake: false,
plugins: [
fixJQueryImport(),
addKendoVersion(),
name === 'kendo.core.js' ? polyfill(['jquery']) : null,
nodeResolve(),
]
});
export default files.map((name) => configMap(name))
.concat(cultures.map((name) => resourcesConfig(name, { dir: 'cultures' })))
.concat(messages.map((name) => resourcesConfig(name, { dir: 'messages' })));