-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
56 lines (53 loc) · 1.43 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
const path = require('path')
const typescript = require('rollup-plugin-typescript2')
const isBuiltinModule = require('is-builtin-module')
const copy = require('rollup-plugin-copy')
function resolveInput(projectDir) {
return path.resolve('packages', `${projectDir}/lib/index.ts`)
}
function resolveOutput(projectDir) {
return path.resolve('packages', `${projectDir}/dist/index.js`)
}
const PKG_DIR = process.env.PKG_DIR
const pkgMeta = require(path.resolve(`packages`, `${PKG_DIR}/package.json`))
const plugins = [
// resolve(),
// commonjs(),
// pluginJson(),
typescript({
tsconfig: `packages/${PKG_DIR}/tsconfig.json`
})
]
if (PKG_DIR === 'website') {
plugins.push(
copy({
targets: [
{ src: 'packages/website/theme', dest: 'packages/website/dist' },
{ src: 'packages/website/bin', dest: 'packages/website/dist' },
{ src: 'packages/website/template', dest: 'packages/website/dist' }
]
})
)
}
module.exports = {
input: resolveInput(PKG_DIR),
external(id) {
return (
(pkgMeta.dependencies && !!pkgMeta.dependencies[id]) ||
id === 'prismjs/components' ||
id === 'vue-template-compiler/build' ||
id === 'typedoc'
)
},
plugins,
output: {
file: resolveOutput(PKG_DIR),
format: 'cjs',
exports: 'named'
},
onwarn(warning, warn) {
if (warning.code === 'UNRESOLVED_IMPORT' && isBuiltinModule(warning.source))
return
warn(warning)
}
}