-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathrollup.build.js
98 lines (91 loc) · 1.96 KB
/
rollup.build.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
const pkg = require("./package.json")
import esbuild from "rollup-plugin-esbuild";
import image from "@rollup/plugin-image"
import resolve from '@rollup/plugin-node-resolve'
import glsl from "./rollup-plugin-glsl"
import jscc from "rollup-plugin-jscc"
const packages = [
"@pixi/assets",
"@pixi/constants",
"@pixi/core",
"@pixi/display",
"@pixi/loaders",
"@pixi/math",
"@pixi/settings",
"@pixi/sprite",
"@pixi/ticker",
"@pixi/utils"
]
const globals = {}
packages.forEach(function (key) {
globals[key] = key === "@pixi/utils" ? "PIXI.utils" : "PIXI"
})
const banner = `/* Pixi3D v${pkg.version} */`
const plugins = ({ compatibility = {}, minify = false } = {}) => [
jscc({
values: {
_PIXI_COMPATIBILITY_LOADERS: compatibility.loaders,
_PIXI_COMPATIBILITY_ASSETS: compatibility.assets,
}
}),
esbuild({
target: "es2017",
minify
}),
image(),
glsl(),
resolve()
]
const config = (file, format, options) => {
return {
input: "src/index.ts",
external: packages,
plugins: plugins(options),
output: [{
file: file,
format: format,
sourcemap: true,
name: "PIXI3D",
globals,
banner,
}]
}
}
const format = (path, format, options = {}) => {
return [
config(path + "pixi3d.js", format, { minify: false, ...options }),
config(path + "pixi3d.min.js", format, { minify: true, ...options }),
]
}
export default [
...format("dist/browser/", "iife", {
compatibility: {
loaders: true,
assets: true
}
}),
...format("dist/cjs/pixi5/", "cjs", {
compatibility: {
loaders: true,
assets: false
}
}),
...format("dist/cjs/pixi7/", "cjs", {
compatibility: {
loaders: false,
assets: true
}
}),
...format("dist/esm/pixi5/", "esm", {
compatibility: {
loaders: true,
assets: false
}
}),
...format("dist/esm/pixi7/", "esm", {
compatibility: {
loaders: false,
assets: true
}
})
]