forked from thednp/bootstrap.native
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.module.js
More file actions
58 lines (48 loc) · 1.53 KB
/
rollup.module.js
File metadata and controls
58 lines (48 loc) · 1.53 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 node from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
import {terser} from 'rollup-plugin-terser'
import cleanup from 'rollup-plugin-cleanup'
import * as pkg from "./package.json";
// set headers
const MODULE = process.env.MODULE
const NAME = MODULE === 'scrollspy' ? 'ScrollSpy' : MODULE.charAt(0).toUpperCase() + MODULE.slice(1)
const year = (new Date).getFullYear()
const banner = `/*!
* Native JavaScript for Bootstrap ${NAME} v${pkg.version} (${pkg.homepage})
* Copyright 2015-${year} © ${pkg.author}
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
*/`
const miniBanner = `// Native JavaScript for Bootstrap ${NAME} v${pkg.version} | ${year} © ${pkg.author} | ${pkg.license}-License`
// set config
const MIN = process.env.MIN === 'true' // true/false|unset
const FORMAT = process.env.FORMAT // umd|iife|esm|cjs
const INPUTFILE = './src/components/'+MODULE+'-native.js'
const OUTPUTFILE = './dist/components/'+MODULE+'-native'+(FORMAT!=='umd'?'.'+FORMAT:'')+(MIN?'.min':'')+'.js'
const OUTPUT = {
file: OUTPUTFILE,
format: FORMAT, // or iife
}
const PLUGINS = [
node({mainFields: ['jsnext', 'module']}),
json(),
buble(),
cleanup()
]
if (MIN){
PLUGINS.push(terser({output: {preamble: miniBanner}}));
} else {
OUTPUT.banner = banner;
// PLUGINS.push(cleanup());
}
if (FORMAT!=='esm') {
OUTPUT.name = NAME;
}
export default [
{
input: INPUTFILE,
output: OUTPUT,
plugins: PLUGINS
}
]