-
Notifications
You must be signed in to change notification settings - Fork 102
/
rollup.config.js
92 lines (78 loc) · 2.24 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 babel from 'rollup-plugin-babel'
import json from 'rollup-plugin-json'
import commonjs from 'rollup-plugin-commonjs'
import resolve from 'rollup-plugin-node-resolve'
import { terser } from 'rollup-plugin-terser'
import { string } from 'rollup-plugin-string'
import replacement from 'rollup-plugin-module-replacement'
import pkg from './package.json'
const banner = (license) => ({
renderChunk(source) {
return `
${license}
${source}`.trim()
}
})
const bundle = (input, output, options = {}) => ({
input: `src/bundles/${input}`,
output: {
name: 'uploadcare',
format: 'umd',
file: `./${output}`,
globals: options.includeJquery
? undefined
: {
jquery: '$'
}
},
external: options.includeJquery ? undefined : ['jquery'],
plugins: [
options.enOnly &&
replacement({
entries: [
{
find: './all-locales',
replacement: require.resolve('./src/locales/en-only-locale.js')
}
]
}),
babel({
exclude: 'node_modules/**',
presets: [['@babel/env', { modules: false }]],
plugins: ['babel-plugin-html-tag']
}),
string({
include: ['src/stylesheets/styles.css', 'src/svgs/icons.html']
}),
json(),
resolve(),
commonjs({
namedExports: { './src/vendor/pusher.js': ['Pusher'] }
}),
terser({
include: [/^.+\.min\.js$/]
}),
banner(`/**
* @license ${pkg.name} v${pkg.version}
*
* Copyright (c) ${new Date().getFullYear()} Uploadcare, Inc.
*
* This source code is licensed under the BSD 2-Clause License
* found in the LICENSE file in the root directory of this source tree.
*/`)
]
})
export default [
bundle('uploadcare.api.js', 'uploadcare.api.js', { enOnly: true }),
bundle('uploadcare.api.js', 'uploadcare.api.min.js', { enOnly: true }),
bundle('uploadcare.js', 'uploadcare.js'),
bundle('uploadcare.js', 'uploadcare.min.js'),
bundle('uploadcare.lang.en.js', 'uploadcare.lang.en.js', { enOnly: true }),
bundle('uploadcare.lang.en.js', 'uploadcare.lang.en.min.js', {
enOnly: true
}),
bundle('uploadcare.full.js', 'uploadcare.full.js', { includeJquery: true }),
bundle('uploadcare.full.js', 'uploadcare.full.min.js', {
includeJquery: true
})
]