forked from MikaelEdebro/vue-airbnb-style-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollupOptions.mjs
50 lines (46 loc) · 1.51 KB
/
rollupOptions.mjs
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
import { babel } from '@rollup/plugin-babel'
const getSupportedBrowsers = () => [
// Supported browsers
'Chrome >= 103',
'Firefox >= 103',
'iOS >= 14',
'Safari >= 14',
'Edge >= 104',
]
/**
* Get config passed to @rollup/plugin-babel
* @returns babel config object
*/
const getBabelConfig = () => ({
exclude: ['node_modules/**'],
babelHelpers: 'bundled', // Default value, helpers rarely (if at all) needed.
babelrc: false,
extensions: ['.js', '.mjs', '.vue'],
targets: getSupportedBrowsers(), // supported browsers.
presets: [
[
'@babel/preset-env',
{
modules: false, // don't convert ESM modules, as that breaks tree shaking
targets: getSupportedBrowsers(), // polyfill based on supported browsers
corejs: {
// use corejs@3 for polyfills
version: '3.26', // see https://github.com/zloirock/core-js#babelpreset-env
},
useBuiltIns: 'usage', // polyfill based on usage in source code.
bugfixes: true, // See https://github.com/babel/babel/issues/13916 (note, we can remove this when Babel 8 is released.
},
],
],
})
/**
* Get array of rollup plugins
* @param {Boolean} includeBabel Whether or not to run build through Babel. Defaults to true but
* used for
* testing.
* @param {Boolean} ssr Whether or not this is the SSR build.
* @returns {Plugin[]|*[]}
*/
const getRollupPlugins = (includeBabel = true, ssr = false) =>
includeBabel ? [babel(getBabelConfig(ssr))] : []
export { getBabelConfig, getRollupPlugins }