forked from rollup/rollup
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
107 lines (102 loc) · 2 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import { readFileSync } from 'fs';
import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import string from 'rollup-plugin-string';
import pkg from './package.json';
const commitHash = (function() {
try {
return readFileSync('.commithash', 'utf-8');
} catch (err) {
return 'unknown';
}
})();
const banner = readFileSync('src/banner.js', 'utf-8')
.replace('${version}', pkg.version)
.replace('${time}', new Date())
.replace('${commitHash}', commitHash);
export default [
/* rollup.js and rollup.es.js */
{
input: 'src/node-entry.js',
plugins: [
json(),
buble({
include: ['src/**', 'node_modules/acorn/**'],
target: {
node: '4'
}
}),
resolve(),
commonjs()
],
external: ['fs', 'path', 'events', 'module'],
banner,
sourcemap: true,
output: [
{ file: 'dist/rollup.js', format: 'cjs' },
{ file: 'dist/rollup.es.js', format: 'es' }
]
},
/* rollup.browser.js */
{
input: 'src/browser-entry.js',
plugins: [
json(),
buble({
include: ['src/**', 'node_modules/acorn/**'],
target: {
node: '4'
}
}),
resolve(),
commonjs(),
{
load: id => {
if ( ~id.indexOf( 'fs.js' ) ) return readFileSync( 'browser/fs.js', 'utf-8' );
if ( ~id.indexOf( 'path.js' ) ) return readFileSync( 'browser/path.js', 'utf-8' );
}
}
],
banner,
sourcemap: true,
output: [
{
file: 'dist/rollup.browser.js',
format: 'umd',
name: 'rollup'
}
]
},
/* bin/rollup */
{
input: 'bin/src/index.js',
plugins: [
string({ include: '**/*.md' }),
json(),
buble({ target: { node: 4 } }),
commonjs({
include: 'node_modules/**'
}),
resolve()
],
external: [
'fs',
'path',
'module',
'events',
'rollup',
'assert',
'os'
],
output: {
file: 'bin/rollup',
format: 'cjs',
banner: '#!/usr/bin/env node',
paths: {
rollup: '../dist/rollup.js'
}
}
}
];