@igstack/app-catalog-frontend-build-vite 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Igor Golovin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,36 @@
1
+ import { ManifestOptions } from 'vite-plugin-pwa';
2
+ export declare function frontendViteConfig(options?: {
3
+ appRoot?: string;
4
+ pwa?: {
5
+ manifest?: Partial<ManifestOptions>;
6
+ registerType?: 'autoUpdate' | 'prompt';
7
+ selfDestroying?: boolean;
8
+ };
9
+ }): {
10
+ server: {
11
+ port: number;
12
+ strictPort: true;
13
+ host: string;
14
+ proxy: {
15
+ '/api': {
16
+ target: string;
17
+ changeOrigin: true;
18
+ cookieDomainRewrite: string;
19
+ };
20
+ '/trpc': {
21
+ target: string;
22
+ changeOrigin: true;
23
+ cookieDomainRewrite: string;
24
+ };
25
+ '/static': {
26
+ target: string;
27
+ changeOrigin: true;
28
+ };
29
+ };
30
+ };
31
+ resolve: {
32
+ conditions: string[];
33
+ };
34
+ publicDir: string;
35
+ plugins: import('vite').PluginOption[];
36
+ };
@@ -0,0 +1,151 @@
1
+ import viteReact from "@vitejs/plugin-react";
2
+ import * as fs from "node:fs";
3
+ import * as sp from "node:path";
4
+ import * as process from "node:process";
5
+ import { VitePWA } from "vite-plugin-pwa";
6
+ import { viteStaticCopy } from "vite-plugin-static-copy";
7
+ import svgr from "vite-plugin-svgr";
8
+ function frontendViteConfig(options) {
9
+ var _a, _b, _c;
10
+ const plugins = [];
11
+ if (options == null ? void 0 : options.appRoot) {
12
+ const appPublicDir = sp.join(options.appRoot, "public");
13
+ plugins.push(
14
+ viteStaticCopy({
15
+ targets: [
16
+ {
17
+ src: "node_modules/@igstack/app-catalog-frontend-core/public/[!.]*",
18
+ dest: "."
19
+ },
20
+ ...fs.existsSync(appPublicDir) ? [
21
+ {
22
+ src: "public/[!.]*",
23
+ dest: "."
24
+ }
25
+ ] : []
26
+ ]
27
+ })
28
+ );
29
+ }
30
+ const registerType = ((_a = options == null ? void 0 : options.pwa) == null ? void 0 : _a.registerType) || (process.env["VITE_AUTO_UPDATE"] === "true" ? "autoUpdate" : "prompt");
31
+ const selfDestroying = ((_b = options == null ? void 0 : options.pwa) == null ? void 0 : _b.selfDestroying) !== void 0 ? options.pwa.selfDestroying : process.env["VITE_SELF_DESTROYING"] === "true" ? true : void 0;
32
+ plugins.push(
33
+ VitePWA({
34
+ registerType,
35
+ selfDestroying,
36
+ workbox: {
37
+ globPatterns: ["**/*.{js,css,html,ico,png,svg}"]
38
+ },
39
+ includeAssets: [
40
+ "favicon.ico",
41
+ "apple-touch-180x180.png",
42
+ "app-catalog-*.png",
43
+ "app-catalog-square.svg"
44
+ ],
45
+ manifest: {
46
+ name: "App Catalog",
47
+ short_name: "EH",
48
+ description: "Jump between environments",
49
+ theme_color: "#1f2937",
50
+ background_color: "#ffffff",
51
+ display: "standalone",
52
+ start_url: "/",
53
+ icons: [
54
+ {
55
+ src: "favicon.ico",
56
+ sizes: "48x48",
57
+ type: "image/x-icon"
58
+ },
59
+ {
60
+ src: "app-catalog-16x16.png",
61
+ sizes: "16x16",
62
+ type: "image/png"
63
+ },
64
+ {
65
+ src: "app-catalog-32x32.png",
66
+ sizes: "32x32",
67
+ type: "image/png"
68
+ },
69
+ {
70
+ src: "app-catalog-48x48.png",
71
+ sizes: "48x48",
72
+ type: "image/png"
73
+ },
74
+ {
75
+ src: "app-catalog-192x192.png",
76
+ sizes: "192x192",
77
+ type: "image/png"
78
+ },
79
+ {
80
+ src: "app-catalog-512x512.png",
81
+ sizes: "512x512",
82
+ type: "image/png"
83
+ },
84
+ {
85
+ src: "app-catalog-square.svg",
86
+ sizes: "150x150",
87
+ type: "image/svg+xml"
88
+ },
89
+ {
90
+ src: "app-catalog-square.svg",
91
+ sizes: "150x150",
92
+ purpose: "maskable",
93
+ type: "image/svg+xml"
94
+ }
95
+ ],
96
+ ...(_c = options == null ? void 0 : options.pwa) == null ? void 0 : _c.manifest
97
+ },
98
+ devOptions: {
99
+ enabled: true
100
+ }
101
+ })
102
+ );
103
+ plugins.push(svgr());
104
+ plugins.push(viteReact());
105
+ if (process.env["NODE_ENV"] === "test") {
106
+ plugins.push({
107
+ name: "load-svg",
108
+ enforce: "pre",
109
+ transform(_, id) {
110
+ if (id.endsWith(".svg?react")) {
111
+ return `export default () => "svg-stub"`;
112
+ }
113
+ return void 0;
114
+ }
115
+ });
116
+ }
117
+ return {
118
+ server: {
119
+ port: 4e3,
120
+ strictPort: true,
121
+ host: "localhost",
122
+ proxy: {
123
+ "/api": {
124
+ target: "http://localhost:4001",
125
+ changeOrigin: true,
126
+ cookieDomainRewrite: "localhost"
127
+ },
128
+ "/trpc": {
129
+ target: "http://localhost:4001",
130
+ changeOrigin: true,
131
+ cookieDomainRewrite: "localhost"
132
+ },
133
+ "/static": {
134
+ target: "http://localhost:4001",
135
+ changeOrigin: true
136
+ }
137
+ }
138
+ },
139
+ resolve: {
140
+ // Use 'my-custom-condition' to resolve @igstack/app-catalog-frontend-core to source files
141
+ // This enables HMR when developing the core library alongside the consuming app
142
+ conditions: ["my-custom-condition"]
143
+ },
144
+ publicDir: ".vite-merged-public",
145
+ plugins
146
+ };
147
+ }
148
+ export {
149
+ frontendViteConfig
150
+ };
151
+ //# sourceMappingURL=frontendViteConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frontendViteConfig.js","sources":["../../src/frontendViteConfig.ts"],"sourcesContent":["import viteReact from '@vitejs/plugin-react'\nimport * as fs from 'node:fs'\nimport * as path from 'node:path'\nimport * as process from 'node:process'\nimport type { UserConfig } from 'vite'\nimport type { ManifestOptions } from 'vite-plugin-pwa'\nimport { VitePWA } from 'vite-plugin-pwa'\nimport { viteStaticCopy } from 'vite-plugin-static-copy'\nimport svgr from 'vite-plugin-svgr'\n\nexport function frontendViteConfig(options?: {\n appRoot?: string\n pwa?: {\n manifest?: Partial<ManifestOptions>\n registerType?: 'autoUpdate' | 'prompt'\n selfDestroying?: boolean\n }\n}) {\n const plugins: UserConfig['plugins'] = []\n\n // Set up static copy for public assets if appRoot is provided\n if (options?.appRoot) {\n const appPublicDir = path.join(options.appRoot, 'public')\n\n // Copy core public assets first, then local public assets (local takes precedence)\n plugins.push(\n viteStaticCopy({\n targets: [\n {\n src: 'node_modules/@igstack/app-catalog-frontend-core/public/[!.]*',\n dest: '.',\n },\n ...(fs.existsSync(appPublicDir)\n ? [\n {\n src: 'public/[!.]*',\n dest: '.',\n },\n ]\n : []),\n ],\n }),\n )\n }\n\n // Configure VitePWA\n const registerType =\n options?.pwa?.registerType ||\n (process.env['VITE_AUTO_UPDATE'] === 'true' ? 'autoUpdate' : 'prompt')\n\n const selfDestroying =\n options?.pwa?.selfDestroying !== undefined\n ? options.pwa.selfDestroying\n : process.env['VITE_SELF_DESTROYING'] === 'true'\n ? true\n : undefined\n\n plugins.push(\n VitePWA({\n registerType,\n selfDestroying,\n workbox: {\n globPatterns: ['**/*.{js,css,html,ico,png,svg}'],\n },\n includeAssets: [\n 'favicon.ico',\n 'apple-touch-180x180.png',\n 'app-catalog-*.png',\n 'app-catalog-square.svg',\n ],\n manifest: {\n name: 'App Catalog',\n short_name: 'EH',\n description: 'Jump between environments',\n theme_color: '#1f2937',\n background_color: '#ffffff',\n display: 'standalone',\n start_url: '/',\n icons: [\n {\n src: 'favicon.ico',\n sizes: '48x48',\n type: 'image/x-icon',\n },\n {\n src: 'app-catalog-16x16.png',\n sizes: '16x16',\n type: 'image/png',\n },\n {\n src: 'app-catalog-32x32.png',\n sizes: '32x32',\n type: 'image/png',\n },\n {\n src: 'app-catalog-48x48.png',\n sizes: '48x48',\n type: 'image/png',\n },\n {\n src: 'app-catalog-192x192.png',\n sizes: '192x192',\n type: 'image/png',\n },\n {\n src: 'app-catalog-512x512.png',\n sizes: '512x512',\n type: 'image/png',\n },\n {\n src: 'app-catalog-square.svg',\n sizes: '150x150',\n type: 'image/svg+xml',\n },\n {\n src: 'app-catalog-square.svg',\n sizes: '150x150',\n purpose: 'maskable',\n type: 'image/svg+xml',\n },\n ],\n ...options?.pwa?.manifest,\n },\n devOptions: {\n enabled: true,\n },\n }),\n )\n\n plugins.push(svgr())\n plugins.push(viteReact())\n\n if (process.env['NODE_ENV'] === 'test') {\n plugins.push({\n name: 'load-svg',\n enforce: 'pre',\n transform(_: string, id: string) {\n if (id.endsWith('.svg?react')) {\n return `export default () => \"svg-stub\"`\n }\n return undefined\n },\n })\n }\n\n // plugins.push(tanstackRouter());\n\n return {\n server: {\n port: 4000,\n strictPort: true,\n host: 'localhost',\n proxy: {\n '/api': {\n target: 'http://localhost:4001',\n changeOrigin: true,\n cookieDomainRewrite: 'localhost',\n },\n '/trpc': {\n target: 'http://localhost:4001',\n changeOrigin: true,\n cookieDomainRewrite: 'localhost',\n },\n '/static': {\n target: 'http://localhost:4001',\n changeOrigin: true,\n },\n },\n },\n resolve: {\n // Use 'my-custom-condition' to resolve @igstack/app-catalog-frontend-core to source files\n // This enables HMR when developing the core library alongside the consuming app\n conditions: ['my-custom-condition'],\n },\n publicDir: '.vite-merged-public',\n plugins,\n } satisfies UserConfig\n}\n"],"names":["path"],"mappings":";;;;;;;AAUO,SAAS,mBAAmB,SAOhC;;AACD,QAAM,UAAiC,CAAA;AAGvC,MAAI,mCAAS,SAAS;AACpB,UAAM,eAAeA,GAAK,KAAK,QAAQ,SAAS,QAAQ;AAGxD,YAAQ;AAAA,MACN,eAAe;AAAA,QACb,SAAS;AAAA,UACP;AAAA,YACE,KAAK;AAAA,YACL,MAAM;AAAA,UAAA;AAAA,UAER,GAAI,GAAG,WAAW,YAAY,IAC1B;AAAA,YACE;AAAA,cACE,KAAK;AAAA,cACL,MAAM;AAAA,YAAA;AAAA,UACR,IAEF,CAAA;AAAA,QAAC;AAAA,MACP,CACD;AAAA,IAAA;AAAA,EAEL;AAGA,QAAM,iBACJ,wCAAS,QAAT,mBAAc,kBACb,QAAQ,IAAI,kBAAkB,MAAM,SAAS,eAAe;AAE/D,QAAM,mBACJ,wCAAS,QAAT,mBAAc,oBAAmB,SAC7B,QAAQ,IAAI,iBACZ,QAAQ,IAAI,sBAAsB,MAAM,SACtC,OACA;AAER,UAAQ;AAAA,IACN,QAAQ;AAAA,MACN;AAAA,MACA;AAAA,MACA,SAAS;AAAA,QACP,cAAc,CAAC,gCAAgC;AAAA,MAAA;AAAA,MAEjD,eAAe;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,MAEF,UAAU;AAAA,QACR,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,aAAa;AAAA,QACb,aAAa;AAAA,QACb,kBAAkB;AAAA,QAClB,SAAS;AAAA,QACT,WAAW;AAAA,QACX,OAAO;AAAA,UACL;AAAA,YACE,KAAK;AAAA,YACL,OAAO;AAAA,YACP,MAAM;AAAA,UAAA;AAAA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,WAAW;AAAA,UACT,QAAQ;AAAA,UACR,cAAc;AAAA,QAAA;AAAA,MAChB;AAAA,IACF;AAAA,IAEF,SAAS;AAAA;AAAA;AAAA,MAGP,YAAY,CAAC,qBAAqB;AAAA,IAAA;AAAA,IAEpC,WAAW;AAAA,IACX;AAAA,EAAA;AAEJ;"}
@@ -0,0 +1,2 @@
1
+ export { frontendViteConfig } from './frontendViteConfig.js';
2
+ export { watchExternalSource, createSourceAliases, createFsAllowPaths, type WatchExternalSourceOptions, } from './watchExternalSource.js';
@@ -0,0 +1,9 @@
1
+ import { frontendViteConfig } from "./frontendViteConfig.js";
2
+ import { createFsAllowPaths, createSourceAliases, watchExternalSource } from "./watchExternalSource.js";
3
+ export {
4
+ createFsAllowPaths,
5
+ createSourceAliases,
6
+ frontendViteConfig,
7
+ watchExternalSource
8
+ };
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}