-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
rollup.config.js
44 lines (37 loc) · 1.13 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
// rollup.config.js
import typescript from '@rollup/plugin-typescript';
import commonjs from '@rollup/plugin-commonjs';
import { terser } from "rollup-plugin-terser";
import json from '@rollup/plugin-json';
const slateESModuleSupport = () => {
const shelljs = require('shelljs');
const finalString = `
function isBackward (selection: Selection): boolean {
var startNode: Node = selection.anchorNode;
var startOffset: number = selection.anchorOffset;
var endNode: Node = selection.focusNode;
var endOffset: number = selection.focusOffset;
var position: number = startNode.compareDocumentPosition(endNode);
return !(position === 4 /* Node.DOCUMENT_POSITION_FOLLOWING */ ||
(position === 0 && startOffset < endOffset));
}
export default isBackward;
`;
const shellFileString = new shelljs.ShellString(finalString);
shellFileString.to('node_modules/selection-is-backward/index.ts');
return;
}
export default {
input: 'src/index.ts',
output: {
file: 'dist/bundle.js',
format: 'cjs'
},
plugins: [
slateESModuleSupport(),
typescript(),
commonjs(),
terser(),
json(),
]
};