-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
60 lines (55 loc) · 1.73 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
import babel from '@rollup/plugin-babel'
import copy from 'rollup-plugin-copy'
import resolve from '@rollup/plugin-node-resolve'
import pkg from './package.json'
const year = new Date().getFullYear()
const banner = (formBuilderName) => `/*!
* Client Side Validations Yup JS (${formBuilderName}) - v${pkg.version} (https://github.com/DavyJonesLocker/client_side_validations-yup)
* Copyright (c) ${year} Geremia Taglialatela
* Licensed under MIT (https://opensource.org/licenses/mit-license.php)
*/
`
const umdModuleConfig = (inputFileName, outputModuleFileName, outputVendorFileName, formBuilderName) => ({
input: `src/${inputFileName}`,
external: ['jquery', '@client-side-validations/client-side-validations'],
output: [
{
file: outputModuleFileName,
banner: banner(formBuilderName),
format: 'umd',
globals: {
jquery: '$',
'@client-side-validations/client-side-validations': 'ClientSideValidations'
}
}
],
plugins: [
resolve(),
babel({ babelHelpers: 'bundled' }),
copy({
targets: [
{ src: outputModuleFileName, dest: 'vendor/assets/javascripts/', rename: outputVendorFileName }
],
hook: 'writeBundle',
verbose: true
})
]
})
const esModuleConfig = (inputFileName, outputModuleFileName, formBuilderName) => ({
input: `src/${inputFileName}`,
external: ['jquery', '@client-side-validations/client-side-validations'],
output: [
{
file: outputModuleFileName,
banner: banner(formBuilderName),
format: 'es'
}
],
plugins: [
babel({ babelHelpers: 'bundled' })
]
})
export default [
umdModuleConfig('main.js', pkg.main, 'rails.validations.yup.js', 'Default'),
esModuleConfig('main.js', pkg.module, 'Default')
]