forked from znck/grammarly
-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
51 lines (47 loc) · 1.37 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
import typescript from '@rollup/plugin-typescript'
import copy from 'rollup-plugin-copy'
import { generateRollupOptions } from '@vuedx/monorepo-tools'
import Path from 'path'
export default [
...generateRollupOptions({
extend(kind, info) {
if (kind === 'dts') return info.rollupOptions
const options = info.rollupOptions
options.plugins.push(typescript({ tsconfig: info.tsconfig.configFile }))
if (info.packageJson.name === 'grammarly' && options.input.endsWith('server.ts')) {
const file = options.output[0].file
options.plugins.push(
wasm(file),
copy({
targets: [
{
src: Path.resolve(
__dirname,
'packages/grammarly-languageserver/node_modules/web-tree-sitter/tree-sitter.wasm',
),
dest: Path.dirname(file),
},
],
}),
)
}
if (
info.packageJson.name === 'grammarly-languageserver' ||
info.packageJson.name === 'grammarly-richtext-encoder'
) {
options.plugins.push(wasm(options.output[0].file))
}
return options
},
}),
]
function wasm(file) {
return copy({
targets: [
{
src: Path.resolve(__dirname, 'parsers/tree-sitter-{html,markdown}.wasm'),
dest: Path.dirname(file),
},
],
})
}