-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrollup.config.js
92 lines (89 loc) · 2.22 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
import url from '@rollup/plugin-url'
import json from '@rollup/plugin-json'
import babel from '@rollup/plugin-babel'
import vue from 'rollup-plugin-vue'
import esbuild from 'rollup-plugin-esbuild'
import replace from '@rollup/plugin-replace'
import commonjs from '@rollup/plugin-commonjs'
import { DEFAULT_EXTENSIONS } from '@babel/core'
import multiInput from 'rollup-plugin-multi-input'
import resolve from '@rollup/plugin-node-resolve'
import filesize from 'rollup-plugin-filesize'
import dts from 'rollup-plugin-dts'
import pkg from './package.json'
const name = 'vue-sparklines'
const externalDeps = Object.keys(pkg.dependencies || {}).concat([/@babel\/runtime/])
const externalPeerDeps = Object.keys(pkg.peerDependencies || {})
const banner = `/**
* ${name} v${pkg.version}
* (c) ${new Date().getFullYear()} ${pkg.author}
* @license ${pkg.license}
*/
`
const input = ['packages/**/*.ts', '!packages/*.d.ts', '!packages/interface.ts']
const getPlugins = () => {
const plugins = [
resolve(),
vue(),
commonjs(),
esbuild({
target: 'esnext',
minify: false,
jsx: 'preserve',
tsconfig: 'tsconfig.json'
}),
babel({
babelHelpers: 'runtime',
extensions: [...DEFAULT_EXTENSIONS, '.vue', '.ts', '.tsx']
}),
json(),
url(),
replace({
preventAssignment: true,
values: {
PKG_VERSION: JSON.stringify(pkg.version)
}
}),
filesize()
]
return plugins
}
const esConfig = {
input,
external: externalDeps.concat(externalPeerDeps),
plugins: [multiInput({
relative: 'packages/'
})].concat(getPlugins()),
output: {
banner,
dir: 'es/',
format: 'esm',
sourcemap: true,
chunkFileNames: '_chunks/dep-[hash].js'
}
}
/** @type {import('rollup').RollupOptions} */
const cjsConfig = {
input,
external: externalDeps.concat(externalPeerDeps),
plugins: [multiInput({
relative: 'packages/'
})].concat(getPlugins()),
output: {
banner,
dir: 'lib/',
format: 'cjs',
sourcemap: true,
exports: 'named',
chunkFileNames: '_chunks/dep-[hash].js'
}
}
const dtsConfig = {
input: 'packages/index.ts',
output: {
banner,
dir: 'type/'
},
plugins: [dts()]
}
export default [esConfig, cjsConfig, dtsConfig]