|
1 |
| -import analogjsangular from "@analogjs/astro-angular"; |
2 |
| -import starlight from "@astrojs/starlight"; |
3 |
| -import tailwind from "@astrojs/tailwind"; |
4 |
| -import { defineConfig } from "astro/config"; |
5 |
| -import { readFileSync } from "node:fs"; |
6 |
| -import { ngtSidebar } from "./astro.sidebar.mjs"; |
7 |
| -import glob from "fast-glob"; |
| 1 | +import analogjsangular from '@analogjs/astro-angular'; |
| 2 | +import starlight from '@astrojs/starlight'; |
| 3 | +import tailwind from '@astrojs/tailwind'; |
| 4 | +import { defineConfig } from 'astro/config'; |
| 5 | +import glob from 'fast-glob'; |
| 6 | +import { readFileSync } from 'node:fs'; |
| 7 | +import { ngtSidebar } from './astro.sidebar.mjs'; |
8 | 8 |
|
9 | 9 | // import starlightBlog from "starlight-blog";
|
10 | 10 |
|
11 | 11 | function devServerFileWatcher(paths) {
|
12 |
| - return { |
13 |
| - name: "dev-server-file-watcher", |
14 |
| - hooks: { |
15 |
| - async "astro:config:setup"({ addWatchFile, config }) { |
16 |
| - for (const path of paths) { |
17 |
| - const files = await glob(path); |
18 |
| - files.forEach((file) => addWatchFile(new URL(file, config.root))); |
19 |
| - } |
20 |
| - }, |
21 |
| - }, |
22 |
| - }; |
| 12 | + return { |
| 13 | + name: 'dev-server-file-watcher', |
| 14 | + hooks: { |
| 15 | + async 'astro:config:setup'({ addWatchFile, config }) { |
| 16 | + for (const path of paths) { |
| 17 | + const files = await glob(path); |
| 18 | + files.forEach((file) => addWatchFile(new URL(file, config.root))); |
| 19 | + } |
| 20 | + }, |
| 21 | + }, |
| 22 | + }; |
23 | 23 | }
|
24 | 24 |
|
25 | 25 | function includeContentPlugin() {
|
26 |
| - const map = new Map(); |
| 26 | + const map = new Map(); |
27 | 27 |
|
28 |
| - return [ |
29 |
| - { |
30 |
| - name: "pre-include-content", |
31 |
| - enforce: "pre", |
32 |
| - transform(_, id) { |
33 |
| - if (!id.includes("?includeContent") || id.includes("astro-entry")) |
34 |
| - return; |
| 28 | + return [ |
| 29 | + { |
| 30 | + name: 'pre-include-content', |
| 31 | + enforce: 'pre', |
| 32 | + transform(_, id) { |
| 33 | + if (!id.includes('?includeContent') || id.includes('astro-entry')) return; |
35 | 34 |
|
36 |
| - const [filePath] = id.split("?"); |
37 |
| - const fileContent = readFileSync(filePath, "utf-8"); |
| 35 | + const [filePath] = id.split('?'); |
| 36 | + const fileContent = readFileSync(filePath, 'utf-8'); |
38 | 37 |
|
39 |
| - if (map.has(filePath)) return; |
40 |
| - map.set(filePath, fileContent.replace(/\t/g, " ")); |
41 |
| - }, |
42 |
| - }, |
43 |
| - { |
44 |
| - name: "post-include-content", |
45 |
| - enforce: "post", |
46 |
| - transform(code, id) { |
47 |
| - if (!id.includes("?includeContent") || id.includes("astro-entry")) |
48 |
| - return; |
49 |
| - const [filePath] = id.split("?"); |
50 |
| - const fileContent = map.get(filePath); |
| 38 | + if (map.has(filePath)) return; |
| 39 | + map.set(filePath, fileContent.replace(/\t/g, ' ')); |
| 40 | + }, |
| 41 | + }, |
| 42 | + { |
| 43 | + name: 'post-include-content', |
| 44 | + enforce: 'post', |
| 45 | + transform(code, id) { |
| 46 | + if (!id.includes('?includeContent') || id.includes('astro-entry')) return; |
| 47 | + const [filePath] = id.split('?'); |
| 48 | + const fileContent = map.get(filePath); |
51 | 49 |
|
52 |
| - return { |
53 |
| - code: ` |
| 50 | + return { |
| 51 | + code: ` |
54 | 52 | ${code}
|
55 | 53 | export const content = ${JSON.stringify(fileContent)};
|
56 | 54 | `,
|
57 |
| - }; |
58 |
| - }, |
59 |
| - }, |
60 |
| - ]; |
| 55 | + }; |
| 56 | + }, |
| 57 | + }, |
| 58 | + ]; |
61 | 59 | }
|
62 | 60 |
|
63 | 61 | // https://astro.build/config
|
64 | 62 | export default defineConfig({
|
65 |
| - vite: { |
66 |
| - esbuild: { |
67 |
| - jsxDev: true, |
68 |
| - }, |
69 |
| - plugins: [includeContentPlugin()], |
70 |
| - ssr: { |
71 |
| - noExternal: [ |
72 |
| - "angular-three-soba/**", |
73 |
| - "angular-three-cannon", |
74 |
| - "angular-three-cannon/**", |
75 |
| - "angular-three-rapier", |
76 |
| - "angular-three-rapier/**", |
77 |
| - "angular-three-postprocessing", |
78 |
| - "angular-three-postprocessing/**", |
79 |
| - "@pmndrs/vanilla", |
80 |
| - "@pmndrs/cannon-worker-api", |
81 |
| - "three-custom-shader-material", |
82 |
| - "postprocessing", |
83 |
| - "stats-gl", |
84 |
| - ], |
85 |
| - }, |
86 |
| - assetsInclude: ["**/*.gltf", "**/*.glb", "**/*.png", "**/*.CUBE"], |
87 |
| - }, |
88 |
| - integrations: [ |
89 |
| - devServerFileWatcher(["./astro.sidebar.mjs"]), |
90 |
| - analogjsangular({ |
91 |
| - vite: { |
92 |
| - transformFilter: (_, id) => { |
93 |
| - // we only transform files in components/scenes |
94 |
| - return id.includes("components/scenes"); |
95 |
| - }, |
96 |
| - }, |
97 |
| - }), |
98 |
| - starlight({ |
99 |
| - title: "Angular Three", |
100 |
| - plugins: [ |
101 |
| - ngtSidebar(), |
102 |
| - // TODO: reenable blog |
103 |
| - // starlightBlog({ |
104 |
| - // authors: { |
105 |
| - // chau: { |
106 |
| - // name: "Chau Tran", |
107 |
| - // url: "https://nartc.me", |
108 |
| - // picture: "https://avatars.githubusercontent.com/u/25516557?v=4", |
109 |
| - // }, |
110 |
| - // }, |
111 |
| - // }), |
112 |
| - ], |
113 |
| - favicon: "./src/assets/angular-three-dark.svg", |
114 |
| - tableOfContents: { |
115 |
| - minHeadingLevel: 2, |
116 |
| - maxHeadingLevel: 4, |
117 |
| - }, |
118 |
| - logo: { |
119 |
| - light: "./src/assets/angular-three.svg", |
120 |
| - dark: "./src/assets/angular-three-dark.svg", |
121 |
| - }, |
122 |
| - social: { |
123 |
| - github: "https://github.com/angular-threejs/angular-three", |
124 |
| - }, |
125 |
| - customCss: ["./src/tailwind.css"], |
126 |
| - }), |
127 |
| - tailwind({ applyBaseStyles: false }), |
128 |
| - ], |
| 63 | + vite: { |
| 64 | + esbuild: { |
| 65 | + jsxDev: true, |
| 66 | + }, |
| 67 | + plugins: [includeContentPlugin()], |
| 68 | + ssr: { |
| 69 | + noExternal: [ |
| 70 | + 'angular-three-soba/**', |
| 71 | + 'angular-three-cannon', |
| 72 | + 'angular-three-cannon/**', |
| 73 | + 'angular-three-rapier', |
| 74 | + 'angular-three-rapier/**', |
| 75 | + 'angular-three-postprocessing', |
| 76 | + 'angular-three-postprocessing/**', |
| 77 | + '@pmndrs/vanilla', |
| 78 | + '@pmndrs/cannon-worker-api', |
| 79 | + 'three-custom-shader-material', |
| 80 | + 'postprocessing', |
| 81 | + 'stats-gl', |
| 82 | + ], |
| 83 | + }, |
| 84 | + assetsInclude: ['**/*.gltf', '**/*.glb', '**/*.png', '**/*.CUBE'], |
| 85 | + }, |
| 86 | + integrations: [ |
| 87 | + devServerFileWatcher(['./astro.sidebar.mjs']), |
| 88 | + analogjsangular({ |
| 89 | + vite: { |
| 90 | + transformFilter: (_, id) => { |
| 91 | + // we only transform files in components/scenes |
| 92 | + return id.includes('components/scenes'); |
| 93 | + }, |
| 94 | + }, |
| 95 | + }), |
| 96 | + starlight({ |
| 97 | + title: 'Angular Three', |
| 98 | + plugins: [ |
| 99 | + ngtSidebar(), |
| 100 | + // TODO: reenable blog |
| 101 | + // starlightBlog({ |
| 102 | + // authors: { |
| 103 | + // chau: { |
| 104 | + // name: "Chau Tran", |
| 105 | + // url: "https://nartc.me", |
| 106 | + // picture: "https://avatars.githubusercontent.com/u/25516557?v=4", |
| 107 | + // }, |
| 108 | + // }, |
| 109 | + // }), |
| 110 | + ], |
| 111 | + favicon: './src/assets/angular-three-dark.svg', |
| 112 | + tableOfContents: { |
| 113 | + minHeadingLevel: 2, |
| 114 | + maxHeadingLevel: 4, |
| 115 | + }, |
| 116 | + logo: { |
| 117 | + light: './src/assets/angular-three.svg', |
| 118 | + dark: './src/assets/angular-three-dark.svg', |
| 119 | + }, |
| 120 | + social: { |
| 121 | + github: 'https://github.com/angular-threejs/angular-three', |
| 122 | + }, |
| 123 | + customCss: ['./src/tailwind.css'], |
| 124 | + }), |
| 125 | + tailwind({ applyBaseStyles: false }), |
| 126 | + ], |
129 | 127 | });
|
0 commit comments