forked from IrisPro/KrpanoToolJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
122 lines (118 loc) · 3.47 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
'use strict';
const path = require('path');
const liveServer = require('rollup-plugin-live-server');
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const typescript = require('rollup-plugin-typescript2');
const sourceMaps = require('rollup-plugin-sourcemaps');
const workerLoader = require('rollup-plugin-web-worker-loader');
const pkg = require('./package.json');
import {terser} from 'rollup-plugin-terser';
import babel from '@rollup/plugin-babel'
import { DEFAULT_EXTENSIONS } from '@babel/core'
const extensions = [
'.js', '.jsx', '.ts', '.tsx',
];
const moduleName = 'KrpanoTool'
const config = [];
if (process.env.TARGET === 'debug') {
config.push({
input: [path.resolve(__dirname, pkg.entry)],
output: {
file: path.resolve(__dirname, pkg.umd),
format: 'umd',
name: moduleName,
sourcemap: true,
},
plugins: [
resolve({
extensions,
browser: true,
preferBuiltins: true,
}),
commonjs(),
typescript({
typescript: require('typescript'),
cacheRoot: path.resolve(__dirname, '.rts2_cache'),
}),
workerLoader(),
babel({
babelHelpers: 'runtime',
exclude: [
'node_modules/**',
'src/modules/panoToCube/panoToCubeWorker.js'
],
extensions: [
...DEFAULT_EXTENSIONS,
'.ts',
],
}),
liveServer({
port: 8990,
host: '0.0.0.0',
root: 'www',
file: 'index.html',
mount: [['/dist', './dist']],
open: false,
wait: 500,
}),
],
});
} else {
config.push({
input: [path.resolve(__dirname, pkg.entry)],
output: [
// esm
{
file: path.resolve(__dirname, pkg['module']),
name: moduleName,
format: 'es',
},
// cjs
{
file: path.resolve(__dirname, pkg['main']),
name: moduleName,
format: 'cjs',
},
// umd
{
name: moduleName,
format: 'umd',
file: path.resolve(__dirname, pkg['umd'])
},
// iife
{
name: moduleName,
file: path.resolve(__dirname, pkg['iife'])
}
],
plugins: [
resolve({
extensions,
browser: true,
preferBuiltins: true,
}),
commonjs(),
typescript({
typescript: require('typescript'),
cacheRoot: path.resolve(__dirname, '.rts2_cache'),
clean: true,
}),
workerLoader(),
babel({
babelHelpers: 'runtime',
exclude: [
'node_modules/**',
'src/modules/panoToCube/panoToCubeWorker.js'
],
extensions: [
...DEFAULT_EXTENSIONS,
'.ts',
],
}),
terser(),
sourceMaps(),
],
});
}
module.exports = config;