-
Notifications
You must be signed in to change notification settings - Fork 1
/
preact.config.js
69 lines (68 loc) · 2.09 KB
/
preact.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
/* eslint-disable @typescript-eslint/no-empty-function */
import CopyWebpackPlugin from 'copy-webpack-plugin';
import path from "path";
import glslLoader from 'webpack-glsl-loader';
export default (config, env, helpers) => {
if (env.isProd) {
config.devtool = false;
}
config.plugins.push(
new CopyWebpackPlugin({
patterns: [{
from: '*.wasm',
context: path.resolve(__dirname, 'node_modules/webrtx/dist'),
}, {
from: '**/*',
to: 'assets',
context: path.resolve(__dirname, 'rt_assets'),
globOptions: {
ignore: [
"**/*.glsl",
// "**/*.vert",
// "**/*.frag",
// "**/*.comp",
// "**/*.rgen",
// "**/*.rint",
// "**/*.rchit",
// "**/*.rahit",
// "**/*.rmiss",
]
}
}, {
// only compile common.glsl
from: '**/*',
to: 'assets',
context: path.resolve(__dirname, 'rt_assets'),
filter: (resourcePath) => {
// TODO: /common.glsl
return resourcePath.endsWith('common.glsl');
},
transform: (content, absoluteFrom) => {
return Promise.resolve(new Promise((resolve, reject) => {
const finalCb = (err, result) => {
if (err) {
reject(err);
} else {
resolve(`#ifndef _SHADOWRAY_PLAYGROUND_COMMON_\n#define _SHADOWRAY_PLAYGROUND_COMMON_\n${result}\n#endif`);
}
};
glslLoader.call({
getOptions: () => ({
omitModuleExports: true
}),
['async']: () => finalCb,
cacheable(flag = true) {},
context: path.dirname(absoluteFrom),
addDependency(f) {},
resolve(context, relativeFilename, cb) {
// just join paths, nothing special
cb(null, path.join(context, relativeFilename));
},
},
content.toString());
}));
},
}]
}),
);
}