forked from DonNicoJs/vue-xlsx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
93 lines (85 loc) · 2.01 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
93
import fs from 'fs';
import cjs from '@rollup/plugin-commonjs'
import vue from 'rollup-plugin-vue';
import replace from '@rollup/plugin-replace';
import node from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import css from 'rollup-plugin-css-only'
import copy from 'rollup-copy-plugin';
import pkg from './package.json'
const baseFolder = './src/';
const componentFolder = 'components/';
const mixinFolder = 'mixins/';
const components = fs.readdirSync(baseFolder + componentFolder);
const mixins = fs.readdirSync(baseFolder + mixinFolder);
const formatOutput = 'esm'
const fileTypesExternal = ['vue', 'xlsx']
const configBabel = {
babelHelpers: 'bundled',
exclude: 'node_modules/**',
}
const configNode = {
extensions: ['.js', '.vue'],
}
const configReplace = {
preventAssignment: true,
values: { 'process.env.NODE_ENV': 'production' },
}
const configVue = {
compileTemplate: true,
css: false,
}
const mapEntry = (f, ext, folder) => ({
input: baseFolder + folder + f,
external: fileTypesExternal,
output: {
format: formatOutput,
dir: `dist/${folder}${f.replace(ext, 'js')}`,
},
plugins: [
replace(configReplace),
node(configNode),
vue(configVue),
cjs(),
],
});
export default [
...components.map(f => mapEntry(f, 'vue', componentFolder)),
...mixins.map(f => mapEntry(f, 'js', mixinFolder)),
{
input: './src/utils.js',
external: fileTypesExternal,
output: {
format: formatOutput,
file: `dist/utils.js`
},
plugins: [
replace(configReplace),
node(configNode),
cjs(),
copy({
'src/index.js': pkg.module,
'src/polyfills.js': 'dist/polyfills.js',
})
],
},
{
input: 'src/index.js',
external: fileTypesExternal,
output: [
{
dir: 'dist',
// file: pkg.main,
format: 'cjs',
}
],
plugins: [
replace(configReplace),
node(configNode),
babel(configBabel),
css(),
vue(configVue),
cjs(),
]
},
];