-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_config.mjs
83 lines (75 loc) · 2.13 KB
/
build_config.mjs
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
import * as path from "path"
import { readFile } from "node:fs/promises"
import { transform } from "@svgr/core"
// START svgr config, only needed if you want to use svgr to
// convert svg files to react components.
const svgrPlugin = () => ({
name: "svgr",
setup(build) {
build.onResolve({ filter: /\.svg$/ }, async (args) => {
// console.log("resolve", args)
// relative import path to absolute file path
return {
path: path.resolve(args.path),
}
})
build.onLoad({ filter: /\.svg$/ }, async (args) => {
const svg = await readFile(args.path, { encoding: "utf8" })
const contents = await transform(
svg,
{
plugins: [
"@svgr/plugin-svgo",
"@svgr/plugin-jsx",
"@svgr/plugin-prettier",
],
replaceAttrValues: {
// Replace the color used in the svg files here, so the components
// can follow current text color.
"#000": "currentColor",
},
svgoConfig: {
plugins: [
{
name: "preset-default",
params: {
overrides: {
// Don't remove viewBox attr
removeViewBox: false,
},
},
},
],
},
},
{ filePath: args.path },
)
// console.log("load", args, svg, contents)
return {
contents,
loader: "jsx",
}
})
},
})
// END svgr
export default {
bundle: true,
sourcemap: true,
// Entry file generated by shadow-cljs
entryPoints: ["dev/gen/libs.js"],
outdir: "resources/public/inventory/assets/js",
resolveExtensions: [".js", ".jsx", ".ts", ".tsx"],
alias: {
src: "./src", // Alias 'src' to the './src' directory
"@/*": "./src/leihs/inventory/client/*",
"@@/*": "src/leihs/inventory/client/components/ui/*",
},
define: {
"process.env.NODE_ENV": `"${process.env.NODE_ENV}"`,
},
target: ["es2020", "chrome119", "firefox120", "safari17", "edge119"],
metafile: true,
logLevel: "info",
plugins: [svgrPlugin()],
}