-
-
Notifications
You must be signed in to change notification settings - Fork 594
/
rollup.config.js
74 lines (69 loc) · 1.79 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
const fs = require('fs-extra');
const path = require('path');
const fg = require('fast-glob');
const { getRootPath, clearDist, external, onwarn, createPlugins } = require('../build/rollup-common-config');
const {
linkVlsInCLI,
bundleVlsWithEsbuild,
watchVlsChange,
generateTypingsVls
} = require('../build/rollup-plugins.js');
const vlsPkg = require('./package.json');
const dts = require('rollup-plugin-dts').default;
const getVLSPath = getRootPath('server');
clearDist(getVLSPath('dist'));
function copySnippets() {
return {
name: 'copy-snippets',
buildEnd() {
fs.copySync(getVLSPath('src/modes/vue/veturSnippets'), getVLSPath('dist/veturSnippets'), {
overwrite: true,
recursive: true
});
}
};
}
function copyTSDefaultLibs() {
return {
name: 'copy-ts-default-libs',
buildEnd() {
const files = fg.sync('node_modules/typescript/lib/lib*.d.ts', {
cwd: getVLSPath(''),
unique: true,
absolute: true
});
files.forEach(file => fs.copySync(file, getVLSPath('dist/' + path.basename(file)), { overwrite: true }));
}
};
}
module.exports = [
// vueServerMain
{
input: getVLSPath('src/vueServerMain.ts'),
output: { file: getVLSPath('dist/vueServerMain.js'), name: vlsPkg.name, format: 'cjs', sourcemap: true },
external,
onwarn,
watch: {
include: getVLSPath('**')
},
plugins: [
watchVlsChange(),
generateTypingsVls(),
bundleVlsWithEsbuild(),
copySnippets(),
// copyTSDefaultLibs(),
linkVlsInCLI(),
...createPlugins(getVLSPath('tsconfig.json'))
]
},
// bundle typings
{
input: getVLSPath('typings/index.d.ts'),
output: {
file: getVLSPath('dist/vls.d.ts'),
format: 'es'
},
onwarn,
plugins: [dts()]
}
];