forked from thednp/spicr
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.js
More file actions
58 lines (46 loc) · 1.59 KB
/
Copy pathrollup.config.js
File metadata and controls
58 lines (46 loc) · 1.59 KB
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
'use strict';
import buble from '@rollup/plugin-buble';
import {terser} from 'rollup-plugin-terser';
import node from '@rollup/plugin-node-resolve';
import json from '@rollup/plugin-json';
import * as pkg from "./package.json";
const STANDALONE = process.env.STANDALONE === 'true'
const MIN = process.env.MIN === 'true' // true/false|unset
const FORMAT = process.env.FORMAT // JS umd|iife|esm
const year = (new Date).getFullYear();
const distribution = STANDALONE ? 'Standalone ' : '';
const banner =
`/*!
* Spicr ${distribution}v${pkg.version} (${pkg.homepage})
* Copyright 2017-${year} © ${pkg.author}
* Licensed under MIT (https://github.com/thednp/spicr/blob/master/LICENSE)
*/`;
const miniBannerJS = `// Spicr ${distribution}v${pkg.version} | ${pkg.author} © ${year} | ${pkg.license}-License`;
let INPUTFILE = process.env.INPUTFILE ? process.env.INPUTFILE : 'src/js/index.js'
let OUTPUTFILE = process.env.OUTPUTFILE ? process.env.OUTPUTFILE : (FORMAT === 'umd' ? 'dist/js/spicr'+(MIN?'.min':'')+'.js' : 'dist/js/spicr.esm'+(MIN?'.min':'')+'.js')
const OUTPUT = {
file: OUTPUTFILE,
format: FORMAT // or iife
};
const PLUGINS = [
json(),
node({mainFields: ['jsnext','module'], dedupe: ['shorter-js','kute.js']})
];
if (FORMAT!=='esm') {
PLUGINS.push(buble({objectAssign: 'Object.assign'}));
}
if (MIN){
PLUGINS.push(terser({output: {preamble: miniBannerJS}}));
} else {
OUTPUT.banner = banner;
}
if (FORMAT!=='esm') {
OUTPUT.name = 'Spicr';
}
export default [
{
input: INPUTFILE,
output: OUTPUT,
plugins: PLUGINS
}
]