forked from playcanvas/texture-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.mjs
55 lines (51 loc) · 1.68 KB
/
rollup.config.mjs
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
import path from 'path';
import copyAndWatch from "./copy-and-watch.mjs";
import resolve from '@rollup/plugin-node-resolve';
import alias from '@rollup/plugin-alias';
import json from '@rollup/plugin-json';
import sourcemaps from 'rollup-plugin-sourcemaps';
import sass from 'rollup-plugin-sass';
const PROD_BUILD = process.env.BUILD_TYPE === 'prod';
const HREF = process.env.BASE_HREF || '';
const ENGINE_DIR = process.env.ENGINE_PATH || 'node_modules/playcanvas';
const PCUI_DIR = process.env.PCUI_PATH || 'node_modules/@playcanvas/pcui';
const ENGINE_NAME = PROD_BUILD ? 'playcanvas.mjs' : 'playcanvas.dbg.mjs';
const ENGINE_PATH = path.resolve(ENGINE_DIR, 'build', ENGINE_NAME);
const PCUI_PATH = path.resolve(PCUI_DIR, 'dist/module/src/index.mjs');
// define supported module overrides
const aliasEntries = {
'playcanvas': ENGINE_PATH,
'pcui': PCUI_PATH
};
export default {
input: 'src/index.js',
output: {
dir: 'dist',
format: 'es',
sourcemap: true
},
plugins: [
copyAndWatch({
targets: [{
src: 'src/index.html',
dest: '',
transform: (contents, filename) => {
return contents.toString().replace('__BASE_HREF__', HREF);
}
},
{ src: 'static/playcanvas-logo.png' },
{ src: 'static/lib' },
{ src: 'static/textures' },
{ src: 'src/fonts.css' }
]}),
alias({ entries: aliasEntries }),
resolve(),
sass({
insert: false,
output: 'dist/style.css',
outputStyle: 'compressed'
}),
sourcemaps(),
json()
]
};