-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
94 lines (90 loc) · 2.36 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
import {uglify} from 'rollup-plugin-uglify';
const license = `
/*-----------------------------------------------------------------------------
| Copyright (c) 2014-2019, Nucleic Development Team & H. Rutjes.
|
| Distributed under the terms of the Modified BSD License.
|
| The full license is in the file COPYING.txt, distributed with this software.
-----------------------------------------------------------------------------*/
`,
banner =
license +
`
/**
* Kiwi is an efficient implementation of the Cassowary constraint solving
* algorithm, based on the seminal Cassowary paper.
* It is *not* a refactoring or port of the original C++ solver, but
* has been designed from the ground up to be lightweight and fast.
*
* **Example**
*
* \`\`\`javascript
* var kiwi = require('kiwi');
*
* // Create a solver
* var solver = new kiwi.Solver();
*
* // Create and add some editable variables
* var left = new kiwi.Variable();
* var width = new kiwi.Variable();
* solver.addEditVariable(left, kiwi.Strength.strong);
* solver.addEditVariable(width, kiwi.Strength.strong);
*
* // Create a variable calculated through a constraint
* var centerX = new kiwi.Variable();
* var expr = new kiwi.Expression([-1, centerX], left, [0.5, width]);
* solver.addConstraint(new kiwi.Constraint(expr, kiwi.Operator.Eq, kiwi.Strength.required));
*
* // Suggest some values to the solver
* solver.suggestValue(left, 0);
* solver.suggestValue(width, 500);
*
* // Lets solve the problem!
* solver.updateVariables();
* assert(centerX.value(), 250);
* \`\`\`
*
* ## API Documentation
* @module kiwi
*/
`;
// we generate three output formats:
// - UMD in lib/kiwi.js
// - minified UMD in lib/kiwi.min.js
// - a fully ES6 version in tmp/kiwi.js, used just as the input to jsdoc2md, as we have
// Typescript set to down-compile the others to ES5 for max compatibility, but
// Typescript's ES5-polyfills confuse jsdoc2md.
const umd = {
input: 'es/kiwi.js',
output: {
file: 'lib/kiwi.js',
format: 'umd',
name: 'kiwi',
exports: 'named',
banner,
},
},
minified = {
...umd,
output: {
...umd.output,
file: 'lib/kiwi.min.js',
},
plugins: [
uglify({
output: {
preamble: license,
},
}),
],
},
doc = {
input: 'tmp/es/kiwi.js',
output: {
...umd.output,
file: 'tmp/kiwi.js',
format: 'es',
},
};
export default [umd, minified, doc];