This repository was archived by the owner on Jul 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathrollup.js
More file actions
72 lines (66 loc) · 2.17 KB
/
Copy pathrollup.js
File metadata and controls
72 lines (66 loc) · 2.17 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
const rollup = require('rollup').rollup;
const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const path = require('path');
const config = {
entry: {
simple: './lib/es6/src/simple/simpleRoot.js',
logo: './lib/es6/src/logo/logoRoot.js',
// TODO: enable these
// todomvc: './lib/es6/src/todomvc/app.js',
// interop: './src/interop/interopRoot.js',
},
};
Object.keys(config.entry)
.forEach(key => {
const entry = config.entry[key];
rollup({
entry: entry, // 'lib/es6/src/' + entry + '.js',
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
}),
nodeResolve({
jsnext: true,
main: true,
module: true,
}),
commonjs({
// non-CommonJS modules will be ignored, but you can also
// specifically include/exclude files
include: 'node_modules/**',
// exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],
// if true then uses of `global` won't be dealt with by this plugin
ignoreGlobal: false,
preferBuiltins: true,
// if false then skip sourceMap generation for CommonJS modules
sourceMap: false,
// explicitly specify unresolvable named exports
// (see below for more details)
namedExports: {
'react': [
'createClass',
'createElement',
],
'react-dom': [
'render'
]
},
// sometimes you have to leave require statements
// unconverted. Pass an array containing the IDs
// or a `id => boolean` function. Only use this
// option if you know what you're doing!
// ignore: [ 'conditional-runtime-dependency' ]
}),
]
})
.then((result) => {
// const filename = last(entry.split('/'));
return result.write({
dest: path.join(__dirname, 'rollupOutputs', key + '.js'),
format: 'iife'
});
})
.catch(console.log);
});