-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
176 lines (161 loc) · 4.61 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
import path from 'path';
import alias from '@rollup/plugin-alias';
import babel from '@rollup/plugin-babel';
import copy from 'rollup-plugin-copy';
import dts from 'rollup-plugin-dts';
import execute from 'rollup-plugin-shell';
import resolve from '@rollup/plugin-node-resolve';
const extensions = ['.ts'];
const globalsMap = {
'@beanbag/spina': 'Spina',
backbone: 'Backbone',
'htm/mini': 'htm',
underscore: '_',
};
const inkPath = path.resolve(__dirname, 'src', 'ink');
const lessArgs = [
'--source-map',
'--include-path=src:node_modules',
`--modify-var="ink-path=${inkPath}"`,
].join(' ');
const cleanCSSArgs = [
'-O2',
'--source-map',
].join(' ');
export default [
{
external: [
'@beanbag/spina',
'babel-plugin-dedent',
'babel-plugin-django-gettext',
'backbone',
'htm',
'htm/mini',
'underscore',
],
input: './src/ink/js/index.ts',
output: [
{
esModule: false,
exports: 'named',
file: `lib/ink.js`,
format: 'umd',
globals: globalsMap,
name: 'Ink',
sourcemap: true,
},
{
dir: 'lib/esm',
exports: 'named',
format: 'esm',
globals: globalsMap,
sourcemap: true,
},
{
dir: 'lib/cjs',
exports: 'named',
format: 'cjs',
globals: globalsMap,
sourcemap: true,
},
],
plugins: [
alias({
entries: [
{
find: '@beanbag/ink',
replacement: path.resolve(
__dirname, 'src', 'ink', 'js'),
},
],
}),
babel({
babelHelpers: 'external',
extensions: extensions,
}),
resolve({
extensions: extensions,
modulePaths: [],
}),
],
/* Don't risk our components disappearing. */
treeshake: false,
},
{
input: './src/babel-preset/index.js',
output: [
{
esModule: false,
file: 'lib/babel-preset/index.js',
format: 'cjs',
sourcemap: true,
},
],
plugins: [
babel({
babelHelpers: 'external',
extensions: extensions,
}),
],
},
{
input: './_build/_ts/index.d.ts',
output: [
{
file: 'lib/index.d.ts',
format: 'es',
},
],
plugins: [
dts.default(),
copy({
targets: [
{
dest: 'lib/esm',
src: 'src/ink/js/index-all.js',
},
{
dest: 'lib',
src: [
'src/ink/less',
'src/ink/images',
'src/ink/ink.less',
],
},
],
}),
/*
* We'll piggy-back off this build, so we only run it once (for the
* one output.
*
* We can't create a build target just for CSS, so this is our
* best option right now.
*/
execute({
commands: [
`lessc ${lessArgs}` +
' lib/less/index.less' +
' lib/ink.css',
`cd lib && cleancss ${cleanCSSArgs}` +
' --format beautify' +
' -o ink.css' +
' ink.css',
`cd lib && cleancss ${cleanCSSArgs}` +
' -o ink.min.css' +
' ink.css',
`lessc ${lessArgs}` +
' lib/less/auto/index.less' +
' lib/ink-auto.css',
`cd lib && cleancss ${cleanCSSArgs}` +
' --format beautify' +
' -o ink-auto.css' +
' ink-auto.css',
`cd lib && cleancss ${cleanCSSArgs}` +
' -o ink-auto.min.css' +
' ink-auto.css',
],
sync: true,
}),
],
},
];