-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
61 lines (58 loc) · 1.72 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
import typescript from 'rollup-plugin-typescript';
import uglify from 'rollup-plugin-uglify';
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import inject from 'rollup-plugin-inject';
export default {
entry: 'src/appworks.ts',
moduleName: "Appworks",
plugins: plugins(),
external: null,
targets: [
{
dest: dest(),
format: 'iife',
sourceMap: true
}
]
};
function dest() {
const pkg = require('./package.json');
if (process.env.BUILD === 'min') {
return pkg['legacy:min'];
} else {
return pkg['legacy'];
}
}
function plugins() {
const use = [];
// as we are using a different version of Typescript to the one supplied by rollup we need to require it here
use.push(typescript({
typescript: require('typescript')
}));
use.push(inject({
// control which files this plugin applies to
// with include/exclude
include: '**/*.ts',
// use a named export – i.e. insert
// import { Promise } from 'es6-promise'
Promise: ['es6-promise', 'Promise'],
}));
// compress assets if BUILD environment variable has been set to `min`
if (process.env.BUILD === 'min') {
use.push(uglify());
}
// this pair of plugins allow us to resolve non-relative imports (such as es6-promise) in our ts files
use.push(nodeResolve({
jsnext: true,
main: true
}));
// map Promise to the physical es5 definition
use.push(commonjs({
include: 'node_modules/**',
namedExports: {
'node_modules/es6-promise/dist/es6-promise.js': ['Promise']
}
}));
return use;
}