-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathrollup.config.js
202 lines (191 loc) · 6.31 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import pkg from './package.json' assert { type: "json" };
import json from '@rollup/plugin-json';
import versionInjector from 'rollup-plugin-version-injector';
export default [
// browser-friendly UMD build
{
input: 'index.js',
output: { name: 'shader-park-core',
file: pkg.browser,
format: 'umd'
},
plugins: [
resolve(), // so Rollup can find `ms`
versionInjector(),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/esprima/dist/esprima.js': ['parse'],
//'node_modules/escodegen/escodegen.js': ['generate']
},
}), // so Rollup can convert `ms` to an ES module
babel({
exclude: ['node_modules/**'],
babelHelpers: "bundled"
}),
json({
// All JSON files will be parsed by default,
// but you can also specifically include/exclude files
include: 'node_modules/**',
//exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false
indent: ' ',
// ignores indent and generates the smallest code
compact: true, // Default: false
})
]
},
// browser-friendly UMD build for p5
{
input: 'targets/p5.js',
output: {
// No dashes so the global variable is easier to access
name: 'shaderPark',
file: pkg.p5,
format: 'umd'
},
plugins: [
resolve(), // so Rollup can find `ms`
versionInjector(),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/esprima/dist/esprima.js': ['parse'],
//'node_modules/escodegen/escodegen.js': ['generate']
},
}), // so Rollup can convert `ms` to an ES module
babel({
exclude: ['node_modules/**'],
babelHelpers: "bundled"
}),
json({
// All JSON files will be parsed by default,
// but you can also specifically include/exclude files
include: 'node_modules/**',
//exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false
indent: ' ',
// ignores indent and generates the smallest code
compact: true, // Default: false
})
]
},
// CommonJS (for Node) and ES module (for bundlers) build.
// (We could have three entries in the configuration array
// instead of two, but it's quicker to generate multiple
// builds from a single configuration where possible, using
// an array for the `output` option, where we can specify
// `file` and `format` for each target)
{
input: 'index.js',
//external: ['escodegen', 'esprima'],
output: [
{ file: pkg.cjs, format: 'cjs' },
{ file: pkg.module, format: 'es' }
],
plugins: [
resolve(), // so Rollup can find `ms`
versionInjector(),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
'node_modules/esprima/dist/esprima.js': ['parse'],
// 'node_modules/escodegen/escodegen.js': ['generate']
},
// include: ['node_modules/**'],
}), // so Rollup can convert `ms` to
babel({
exclude: ['node_modules/**'],
babelHelpers: "bundled"
}),
json({
// All JSON files will be parsed by default,
// but you can also specifically include/exclude files
include: 'node_modules/**',
//exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false
indent: ' ',
// ignores indent and generates the smallest code
compact: true, // Default: false
})
]
},
// Minimal Renderer
{
input: 'targets/minimalGLSLRenderer.js',
output: [
{ file: pkg.minimalGLSLRendererCJS, format: 'cjs' },
{ file: pkg.minimalGLSLRendererESM, format: 'es' }
],
plugins: [
resolve(), // so Rollup can find `ms`
versionInjector(),
commonjs({
namedExports: {
// left-hand side can be an absolute path, a path
// relative to the current directory, or the name
// of a module in node_modules
// 'node_modules/esprima/dist/esprima.js': ['parse'],
},
// include: ['node_modules/**'],
}), // so Rollup can convert `ms` to
babel({
exclude: ['node_modules/**'],
babelHelpers: "bundled"
}),
json({
// All JSON files will be parsed by default,
// but you can also specifically include/exclude files
include: 'node_modules/**',
//exclude: ['node_modules/foo/**', 'node_modules/bar/**'],
// for tree-shaking, properties will be declared as
// variables, using either `var` or `const`
preferConst: true, // Default: false
indent: ' ',
// ignores indent and generates the smallest code
compact: true, // Default: false
})
]
},
//TouchDesigner
{
input: 'targets/touchDesigner.js',
output: { name: 'SPTD',
file: pkg.TouchDesigner,
format: 'umd'
},
plugins: [
resolve(), // so Rollup can find `ms`
versionInjector(),
commonjs({
namedExports: { 'node_modules/esprima/dist/esprima.js': ['parse'],
},
}),
babel({
exclude: ['node_modules/**'],
babelHelpers: "bundled"
}),
json({
include: 'node_modules/**',
preferConst: true, // Default: false
indent: ' ',
compact: true, // Default: false
})
]
}
];