-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
81 lines (74 loc) · 2.23 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
/**
* Rollup Core
*/
import nodeResolve from '@rollup/plugin-node-resolve';
/**
* ES6 To ES5
*/
import babel from '@rollup/plugin-babel';
/**
* Minify
*/
import { terser } from "rollup-plugin-terser";
import compiler from '@ampproject/rollup-plugin-closure-compiler';
import gzipPlugin from 'rollup-plugin-gzip'
/**
* Utility
*/
import license from 'rollup-plugin-license';
import filesize from 'rollup-plugin-filesize';
import visualizer from 'rollup-plugin-visualizer';
import json from '@rollup/plugin-json';
import replace from "@rollup/plugin-replace";
/**
* Package.JSON
*/
import pkg from "./package.json";
const _name = 'domq';
const input_bundled = './src/export/bundled.js';
const input_standlone = './src/export/standlone.js';
const files = [
{ input: input_bundled, format: 'es', minify: false, type: 'bundled' },
{ input: input_bundled, format: 'umd', minify: false, type: 'bundled' },
{ input: input_bundled, format: 'umd', minify: true, type: 'bundled' },
{ input: input_bundled, format: 'umd', minify: true, gzip: true, type: 'bundled' },
{ input: input_standlone, format: 'es', minify: false, type: 'standalone' },
{ input: input_standlone, format: 'umd', minify: false, type: 'standalone' },
{ input: input_standlone, format: 'umd', minify: true, type: 'standalone' },
{ input: input_standlone, format: 'umd', minify: true, gzip: true, type: 'standalone' },
];
const config = files.map( ( { input, format, minify, gzip, type } ) => {
return {
input: input,
output: {
file: `./dist/${type}/${_name}.${format}${minify ? '.min' : ''}.js`,
format: format,
name: _name,
sourcemap: true,
},
plugins: [
replace( { '__SHORTNAME__': _name } ),
nodeResolve(),
json(),
babel( { babelHelpers: 'bundled' } ),
minify && compiler(),
minify && terser( {
output: {
beautify: false,
quote_style: 1,
},
mangle: true
} ),
gzip && gzipPlugin(),
license( {
banner: `${pkg.name} v${pkg.version} | <%= moment().format('DD-MM-YYYY') %> - MIT License`
} ),
filesize(),
visualizer( {
sourcemap: true,
filename: `stats/${type}.${format}${minify ? '.min' : ''}${gzip ? '.gz' : ''}.html`,
} )
].filter( Boolean )
};
} ).flat();
export default config;