-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
92 lines (85 loc) · 2.08 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 vuePlugin from 'rollup-plugin-vue';
import esbuild from 'rollup-plugin-esbuild';
import postcss from 'rollup-plugin-postcss';
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 nodeResolve from '@rollup/plugin-node-resolve';
import staticImport from 'rollup-plugin-static-import';
import pkg from './package.json';
const name = 'vion';
const externalDeps = Object.keys(pkg.peerDependencies).concat([/@babel\/runtime/]);
const banner = `/**
* ${name} v${pkg.version}
* (c) ${new Date().getFullYear()} ${pkg.author}
* @license ${pkg.license}
*/
`;
const getPlugins = () => {
const plugins = [
multiInput(),
vuePlugin(),
nodeResolve(),
commonjs(),
esbuild({
target: 'esnext',
minify: false,
}),
babel({
babelHelpers: 'runtime',
extensions: [...DEFAULT_EXTENSIONS, '.vue'],
}),
json(),
url(),
replace({
preventAssignment: true,
values: {
__VERSION__: JSON.stringify(pkg.version),
},
}),
];
return plugins;
};
const esConfig = {
input: ['src/*/index.js', 'src/index-es.js'],
external: externalDeps,
plugins: [
...getPlugins(),
staticImport({
include: ['src/**/style.js', 'src/style/**/*.{less,svg,png,ttf}', 'src/locale/lang/*.js'],
}),
],
output: {
banner,
dir: 'es/',
format: 'esm',
sourcemap: true,
},
};
const cjsConfig = {
input: ['src/*/index.js', 'src/index.js'],
external: externalDeps,
plugins: [
...getPlugins(),
staticImport({
include: ['src/style/**/*.{svg,png}', 'src/locale/lang/*.js'],
}),
postcss({
extract: 'style/index.css',
minimize: true,
extensions: ['.css', '.less'],
}),
],
output: {
banner,
dir: 'lib/',
format: 'cjs',
sourcemap: true,
exports: 'named',
},
};
export default [esConfig, cjsConfig];