forked from troisjs/trois
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.js
More file actions
94 lines (88 loc) · 2.62 KB
/
Copy pathrollup.config.js
File metadata and controls
94 lines (88 loc) · 2.62 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// import vue from 'rollup-plugin-vue'
import esbuild from "rollup-plugin-esbuild";
import replace from "@rollup/plugin-replace";
import dts from "rollup-plugin-dts";
const input = "src/export.ts";
const external = [
"three",
"three/examples/jsm/controls/OrbitControls.js",
"three/examples/jsm/deprecated/Geometry.js",
"three/examples/jsm/geometries/TextGeometry.js",
"three/examples/jsm/helpers/RectAreaLightHelper.js",
"three/examples/jsm/lights/RectAreaLightUniformsLib.js",
"three/examples/jsm/loaders/FontLoader.js",
"three/examples/jsm/loaders/FBXLoader.js",
"three/examples/jsm/loaders/GLTFLoader.js",
"three/examples/jsm/postprocessing/BokehPass.js",
"three/examples/jsm/postprocessing/EffectComposer.js",
"three/examples/jsm/postprocessing/FilmPass.js",
"three/examples/jsm/postprocessing/HalftonePass.js",
"three/examples/jsm/postprocessing/RenderPass.js",
"three/examples/jsm/postprocessing/Pass.js",
"three/examples/jsm/postprocessing/SAOPass.js",
"three/examples/jsm/postprocessing/SSAOPass.js",
"three/examples/jsm/postprocessing/SMAAPass.js",
"three/examples/jsm/postprocessing/ShaderPass.js",
"three/examples/jsm/postprocessing/UnrealBloomPass.js",
"three/examples/jsm/shaders/FXAAShader.js",
"three/examples/jsm/webxr/VRButton.js",
"vue",
"@nativescript/core",
"@nativescript/core/platform",
"@nativescript/canvas",
"@nativescript/canvas-polyfill",
];
const cdnReplaces = {
"from 'vue'":
"from 'https://unpkg.com/vue@3.2.20/dist/vue.esm-browser.prod.js'",
"from 'three'":
"from 'https://cdn.skypack.dev/three@0.136.0/build/three.module.js'",
"from 'three/examples":
"from 'https://cdn.skypack.dev/three@0.136.0/examples",
delimiters: ["", ""],
};
function createConfig(format, output, plugins = [], minify = false) {
const tsPlugin = esbuild({
sourceMap: true,
minify,
target: "es2019",
});
return {
input,
external,
output: {
format,
...output,
// exports: 'named',
sourcemap: true,
},
plugins: [
...plugins,
// vue(),
tsPlugin,
],
};
}
export default [
createConfig("es", { file: "build/trois.module.cdn.js" }, [
replace(cdnReplaces),
]),
createConfig(
"es",
{ file: "build/trois.module.cdn.min.js" },
[replace(cdnReplaces)],
true
),
createConfig("es", { file: "build/trois.module.js" }),
createConfig("es", { file: "build/trois.module.min.js" }, [], true),
createConfig("cjs", { file: "build/trois.js" }),
{
input: "types/export.d.ts",
external,
plugins: [dts()],
output: {
format: "es",
file: "build/trois.d.ts",
},
},
];