forked from atomiks/tippyjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
143 lines (136 loc) · 3.29 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import babel from 'rollup-plugin-babel';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';
import cssOnly from 'rollup-plugin-css-only';
import replace from 'rollup-plugin-replace';
import {terser} from 'rollup-plugin-terser';
import pkg from './package.json';
const NAMESPACE_PREFIX = process.env.NAMESPACE || 'tippy';
const PLUGINS = {
babel: babel({extensions: ['.js', '.ts']}),
replaceNamespace: replace({
__NAMESPACE_PREFIX__: NAMESPACE_PREFIX,
}),
replaceEnvProduction: replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
replaceEnvDevelopment: replace({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
minify: terser(),
resolve: resolve({extensions: ['.js', '.ts']}),
css: cssOnly({output: false}),
json: json(),
};
const COMMON_PLUGINS = [
PLUGINS.replaceNamespace,
PLUGINS.resolve,
PLUGINS.json,
];
const PLUGIN_CONFIGS = {
base: [PLUGINS.babel, ...COMMON_PLUGINS],
bundle: [PLUGINS.babel, ...COMMON_PLUGINS, PLUGINS.css],
iifeBase: [PLUGINS.babel, PLUGINS.replaceEnvDevelopment, ...COMMON_PLUGINS],
iifeBaseMin: [
PLUGINS.babel,
PLUGINS.replaceEnvProduction,
...COMMON_PLUGINS,
PLUGINS.minify,
],
iifeBundle: [
PLUGINS.babel,
PLUGINS.replaceEnvDevelopment,
...COMMON_PLUGINS,
PLUGINS.css,
],
iifeBundleMin: [
PLUGINS.babel,
PLUGINS.replaceEnvProduction,
...COMMON_PLUGINS,
PLUGINS.minify,
PLUGINS.css,
],
};
const BANNER = `/**!
* tippy.js v${pkg.version}
* (c) 2017-${new Date().getFullYear()} atomiks
* MIT License
*/`;
const COMMON_IIFE_OUTPUT_OPTIONS = {
globals: {'popper.js': 'Popper'},
format: 'iife',
name: 'tippy',
esModule: false,
sourcemap: true,
};
export default [
{
input: 'build/base-iife.js',
plugins: PLUGIN_CONFIGS.iifeBase,
external: ['popper.js'],
output: {
...COMMON_IIFE_OUTPUT_OPTIONS,
file: 'dist/tippy.iife.js',
banner: BANNER,
},
},
{
input: 'build/bundle-iife.js',
plugins: PLUGIN_CONFIGS.iifeBundle,
external: ['popper.js'],
output: {
...COMMON_IIFE_OUTPUT_OPTIONS,
file: 'dist/tippy-bundle.iife.js',
banner: BANNER,
},
},
{
input: 'build/base-iife.js',
plugins: PLUGIN_CONFIGS.iifeBaseMin,
external: ['popper.js'],
output: {
...COMMON_IIFE_OUTPUT_OPTIONS,
file: 'dist/tippy.iife.min.js',
},
},
{
input: 'build/bundle-iife.js',
plugins: PLUGIN_CONFIGS.iifeBundleMin,
external: ['popper.js'],
output: {
...COMMON_IIFE_OUTPUT_OPTIONS,
file: 'dist/tippy-bundle.iife.min.js',
},
},
{
input: {
'dist/tippy.esm': 'build/base.js',
'dist/tippy-bundle.esm': 'build/bundle.js',
},
plugins: PLUGIN_CONFIGS.bundle,
external: ['popper.js'],
output: {
format: 'esm',
dir: './',
banner: BANNER,
sourcemap: true,
chunkFileNames: 'dist/tippy.chunk.esm.js',
},
},
{
input: {
'dist/tippy.cjs': 'build/base.js',
'dist/tippy-bundle.cjs': 'build/bundle.js',
},
plugins: PLUGIN_CONFIGS.bundle,
external: ['popper.js'],
output: {
format: 'cjs',
dir: './',
exports: 'named',
banner: BANNER,
sourcemap: true,
chunkFileNames: 'dist/tippy.chunk.cjs.js',
},
},
];