-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.js
58 lines (57 loc) · 1.56 KB
/
setup.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
import Atomico from "@atomico/vite";
/**
*
* @returns {import("astro").AstroRenderer}
*/
function getRenderer() {
return {
name: "@atomico/astro",
clientEntrypoint: "@atomico/astro/client",
serverEntrypoint: "@atomico/astro/server",
jsxImportSource: "atomico",
jsxTransformOptions: async () => {
const {
default: { default: jsx },
} = await import("@babel/plugin-transform-react-jsx");
return {
plugins: [jsx({}, { runtime: "automatic", importSource: "atomico" })],
};
},
};
}
/**
* @param {object} options
* @param {object} [options.cssLiterals]
* @param {boolean} [options.cssLiterals.minify]
* @param {boolean} [options.cssLiterals.postcss]
* @param {string} [options.tsconfig]
* @param {object} [options.customElements]
* @param {string} options.customElements.prefix
* @param {string[]} options.customElements.define
* @returns {import("astro").AstroIntegration}
*/
export default function atomicoAstro({
cssLiterals = { minify: false, postcss: false },
tsconfig,
customElements,
} = {}) {
return {
name: "@atomico/astro",
hooks: {
"astro:config:setup": ({ addRenderer, updateConfig }) => {
addRenderer(getRenderer());
updateConfig({
vite: {
optimizeDeps: {
include: ["atomico", "atomico/jsx-runtime"],
exclude: ["@atomico/astro/server"],
},
plugins: [
Atomico({ jsx: false, cssLiterals, tsconfig, customElements }),
],
},
});
},
},
};
}