-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
71 lines (57 loc) · 1.51 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
// Plugins
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
// Configs
var configs = {
name: 'portal',
files: ['main.js'],
themes: ['default', 'sidebar', 'skinny-nav'],
default: 'iife',
minify: true,
sourceMap: false
};
// Banner
var banner = `/*! ${pkg.name} v${pkg.version} | (c) ${new Date().getFullYear()} ${pkg.author.name} | ${pkg.license} | ${pkg.repository.url} */`;
var createOutput = function (filename, minify) {
return configs.themes.map(function (theme) {
var output = {
file: `dist/${theme}/js/${filename}${minify ? '.min' : ''}.js`,
format: 'iife',
banner: banner
};
if (minify) {
output.plugins = [terser()];
}
output.sourcemap = configs.sourceMap
return output;
});
};
/**
* Create output formats
* @param {String} filename The filename
* @return {Array} The outputs array
*/
var createOutputs = function (filename) {
// Create base outputs
var outputs = createOutput(filename);
// If not minifying, return outputs
if (!configs.minify) return outputs;
// Otherwise, ceate second set of outputs
var outputsMin = createOutput(filename, true);
// Merge and return the two arrays
return outputs.concat(outputsMin);
};
/**
* Create export object
* @return {Array} The export object
*/
var createExport = function (file) {
return configs.files.map(function (file) {
var filename = file.replace('.js', '');
return {
input: `src/js/${file}`,
output: createOutputs(filename)
};
});
};
export default createExport();