forked from bootstrap-vue/bootstrap-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
127 lines (114 loc) · 3.3 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import fs from 'fs'
import path from 'path'
import babel from 'rollup-plugin-babel'
import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import { camelCase } from 'lodash'
import { name, dependencies } from '../package.json'
const bannerComment = require('./banner')
const bannerIconsComment = bannerComment.replace('* BootstrapVue', '* BootstrapVueIcons')
const base = path.resolve(__dirname, '..')
const src = path.resolve(base, 'src')
const dist = path.resolve(base, 'dist')
const externals = ['vue', ...Object.keys(dependencies)]
// Libs in `external` will not be bundled to dist, since they
// are expected to be provided later.
// In some cases (i.e. browser UMD build), we want to include some of
// them in the build, so we exclude the external here.
const externalExcludes = ['popper.js', 'portal-vue', 'vue-functional-data-merge']
// The base rollup configuration
const baseConfig = {
input: path.resolve(src, 'index.js'),
external: externals,
plugins: [resolve({ external: ['vue'] }), commonjs(), babel({ exclude: 'node_modules/**' })]
}
// Ensure dist directory exists
if (!fs.existsSync(dist)) {
fs.mkdirSync(dist)
}
export default [
// UMD Browser Build
{
...baseConfig,
// We use a specific input for the browser build
input: path.resolve(src, 'browser.js'),
external: externals.filter(dep => !externalExcludes.includes(dep)),
output: {
format: 'umd',
name: camelCase(name),
file: path.resolve(dist, `${name}.js`),
banner: bannerComment,
sourcemap: true,
globals: {
vue: 'Vue'
}
}
},
// UMD Icons only Browser Build
{
...baseConfig,
// We use a specific input for the browser build
input: path.resolve(src, 'browser-icons.js'),
external: externals.filter(dep => !externalExcludes.includes(dep)),
output: {
format: 'umd',
name: camelCase(`${name}-icons`),
file: path.resolve(dist, `${name}-icons.js`),
banner: bannerIconsComment,
sourcemap: true,
globals: {
vue: 'Vue'
}
}
},
// COMMONJS Module Build
{
...baseConfig,
output: {
format: 'cjs',
name: camelCase(name),
file: path.resolve(dist, `${name}.common.js`),
banner: bannerComment,
sourcemap: true,
// Disable warning about mixed named/default exports
// We we have handled this in the index file
exports: 'named'
}
},
// COMMONJS Icons only Module Build
{
...baseConfig,
input: path.resolve(src, 'icons-only.js'),
output: {
format: 'cjs',
name: camelCase(`${name}-icons`),
file: path.resolve(dist, `${name}-icons.common.js`),
banner: bannerComment,
sourcemap: true,
// Disable warning about mixed named/default exports
// We we have handled this in the index file
exports: 'named'
}
},
// ESM Module Bundle Build
{
...baseConfig,
output: {
format: 'es',
file: path.resolve(dist, `${name}.esm.js`),
banner: bannerComment,
sourcemap: true
}
},
// ESM Icons only Module Bundle Build
{
...baseConfig,
input: path.resolve(src, 'icons-only.js'),
output: {
format: 'es',
file: path.resolve(dist, `${name}-icons.esm.js`),
banner: bannerComment,
sourcemap: true
}
}
]