-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathrollup.config.js
70 lines (68 loc) · 2.01 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
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import serve from "rollup-plugin-serve";
import livereload from 'rollup-plugin-livereload';
import { uglify } from 'rollup-plugin-uglify';
import rollupTypescript from 'rollup-plugin-typescript2';
import replace from 'rollup-plugin-replace';
import fs from 'fs';
const debug = process.env.NODE_ENV === 'development' ? true : false;
const combineFiles = [
'./node_modules/three/build/three.js',
'./node_modules/three/examples/js/loaders/GLTFLoader.js',
'./node_modules/three/examples/js/controls/OrbitControls.js',
'./node_modules/@tweenjs/tween.js/src/Tween.js'
];
var banner = '';
for (let file of combineFiles) {
banner += fs.readFileSync(file, { encoding: 'utf-8' });
}
export default {
input: './src/Index.ts',
external: ['three', '@tweenjs/tween.js'],
onwarn: warning => { if (warning.code == 'PLUGIN_WARNING') return; },
output: {
file: './build/thing.js',
format: 'umd',
name: 'THING',
sourcemap: debug,
banner: banner,
globals: {
'three': 'THREE',
'@tweenjs/tween.js': 'TWEEN'
}
},
plugins: [
rollupTypescript(),
resolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
babel({
exclude: './node_modules/**',
runtimeHelpers: true,
babelrc: false,
presets: [
['@babel/preset-env', { modules: false }]
]
}),
replace({
ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}),
(!debug && uglify()),
(debug && serve({
open: true,
verbose: false,
contentBase: './',
host: '0.0.0.0',
port: 80
})),
(debug && livereload({
watch: './build',
verbose: false
}))
]
}