-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcraco.config.ts
44 lines (41 loc) · 1.29 KB
/
craco.config.ts
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
import type { CracoConfig } from "@craco/types";
import { PluginOptions } from "copy-webpack-plugin";
import { dirname, join } from "path";
const CopyPlugin = require("copy-webpack-plugin");
const tfjsWasmBackend = dirname(
dirname(require.resolve("@tensorflow/tfjs-backend-wasm")),
);
const modelFiles = "*.{js,tflite,data,wasm,binarypb}";
const mediapipeFaceDetection = dirname(
require.resolve("@mediapipe/face_detection"),
);
const mediapipeSelfie = dirname(
require.resolve("@mediapipe/selfie_segmentation"),
);
const ov: CracoConfig = {
webpack: {
configure: (webpackConfig) => {
const outDir = webpackConfig.output!.path!;
const output = join(dirname(outDir), "build", "static");
const options: PluginOptions = {
patterns: [
{
from: join(tfjsWasmBackend, "wasm-out"),
to: join(output, "tfjs", "[name][ext]"),
},
{
from: join(mediapipeFaceDetection, modelFiles),
to: join(output, "face", "[name][ext]"),
},
{
from: join(mediapipeSelfie, modelFiles),
to: join(output, "selfie", "[name][ext]"),
},
],
};
webpackConfig.plugins?.push(new CopyPlugin(options));
return webpackConfig;
},
},
};
module.exports = ov;