-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrollup.config.js
92 lines (86 loc) · 2.52 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 clear from 'rollup-plugin-clear';
import commonjs from '@rollup/plugin-commonjs';
import cssnano from 'cssnano';
import filesize from 'rollup-plugin-filesize';
import resolve from '@rollup/plugin-node-resolve';
import styles from 'rollup-plugin-styles';
import typescript from '@rollup/plugin-typescript';
import { terser } from 'rollup-plugin-terser';
const modules = {
'@flasher/flasher': { name: 'flasher', output: 'dist/flasher.js' },
'@flasher/flasher-noty': { name: 'flasher.noty', output: 'dist/flasher-noty.js' },
'@flasher/flasher-notyf': { name: 'flasher.notyf', output: 'dist/flasher-notyf.js' },
'@flasher/flasher-pnotify': { name: 'flasher.pnotify', output: 'dist/flasher-pnotify.js' },
'@flasher/flasher-sweetalert': { name: 'flasher.sweetalert', output: 'dist/flasher-sweetalert.js' },
'@flasher/flasher-toastr': { name: 'flasher.toastr', output: 'dist/flasher-toastr.js' },
};
const packageName = process.env.LERNA_PACKAGE_NAME;
const module = modules[packageName];
if ('@flasher/flasher' !== packageName) {
module.globals = { '@flasher/flasher': 'flasher' };
module.external = ['@flasher/flasher'];
if (-1 === ['@flasher/flasher-notyf', '@flasher/flasher-noty'].indexOf(packageName)) {
module.external.push('jquery');
module.globals.jquery = 'jQuery';
}
}
const isProduction = 'production' === process.env.NODE_ENV;
export default {
input: 'src/index.ts',
plugins: [
clear({
targets: ['dist'],
}),
styles({
mode: 'extract',
plugins: {
cssnano,
"postcss-discard-comments": {
removeAll: true,
},
},
}),
resolve(),
commonjs(),
typescript({
tsconfig: 'tsconfig.build.json',
}),
],
external: module.external || [],
output: [
{
dir: 'dist',
format: 'cjs',
exports: 'auto',
sourcemap: !isProduction,
assetFileNames: '[name][extname]',
},
{
file: module.output,
format: 'umd',
exports: 'auto',
sourcemap: !isProduction,
assetFileNames: '[name][extname]',
name: module.name,
globals: module.globals || {},
},
{
file: module.output.replace('.js', '.min.js'),
format: 'umd',
exports: 'auto',
sourcemap: !isProduction,
assetFileNames: '[name][extname]',
name: module.name,
globals: module.globals || {},
plugins: [
isProduction &&
terser({
format: {
comments: false,
},
}),
filesize(),
],
},
],
};