forked from easepick/easepick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
121 lines (111 loc) · 2.78 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
import typescript from '@rollup/plugin-typescript';
import define from 'rollup-plugin-define';
import resolve from '@rollup/plugin-node-resolve';
import postcss from 'rollup-plugin-postcss';
import autoprefixer from 'autoprefixer';
import { terser } from 'rollup-plugin-terser';
const path = require('path');
const pkg = require('./package.json');
const ENV_PROD = process.env.BUILD === 'production';
const output = (name) => {
const pkg = require(path.join(__dirname, `packages/${name}/package.json`));
return [
{
file: `packages/${name}/dist/index.umd.js`,
format: 'umd',
name: 'easepick',
sourcemap: false,
extend: true,
banner: `/**
* @license
* Package: ${pkg.name}
* Version: ${pkg.version}
* https://easepick.com/
* Copyright ${(new Date()).getFullYear()} Rinat G.
*
* Licensed under the terms of GNU General Public License Version 2 or later. (http://www.gnu.org/licenses/gpl.html)
*/`,
globals(id) {
if (/^@easepick\//.test(id)) {
return 'easepick';
}
return id;
}
},
{
file: `packages/${name}/dist/index.esm.js`,
format: 'esm',
sourcemap: false,
extend: true,
},
];
}
const input = (name) => {
return `packages/${name}/src/index.ts`;
}
const getPackageConfig = (name) => {
return {
input: input(name),
output: output(name),
plugins: [
define({
replacements: {
__VERSION__: JSON.stringify(pkg.version),
}
}),
resolve({
resolveOnly: [/^@easepick\/.*$/]
}),
typescript({
tsconfig: `packages/${name}/tsconfig.json`,
outputToFilesystem: false,
}),
postcss({
extract: 'index.css',
plugins: [autoprefixer],
minimize: ENV_PROD,
}),
ENV_PROD && terser(),
],
external(id) {
return /^@easepick\//.test(id);
}
};
}
export default [
getPackageConfig('datetime'),
getPackageConfig('core'),
getPackageConfig('base-plugin'),
getPackageConfig('lock-plugin'),
getPackageConfig('range-plugin'),
getPackageConfig('preset-plugin'),
getPackageConfig('time-plugin'),
getPackageConfig('kbd-plugin'),
getPackageConfig('amp-plugin'),
// @easepick/bundle
{
input: 'packages/bundle/src/index.ts',
output: output('bundle'),
plugins: [
define({
replacements: {
__VERSION__: JSON.stringify(pkg.version),
}
}),
resolve({
dedupe: ['@easepick/base-plugin'],
resolveOnly: [/^@easepick\/.*$/]
}),
typescript({
tsconfig: 'packages/bundle/tsconfig.json',
outputToFilesystem: false,
}),
postcss({
extract: 'index.css',
plugins: [autoprefixer],
minimize: ENV_PROD,
}),
ENV_PROD && terser(),
],
},
]