@env-hopper/frontend-build-vite 2.0.1-alpha.0 → 2.0.1-alpha.6
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/dist/esm/frontendViteConfig.d.ts +28 -4
- package/dist/esm/frontendViteConfig.js +134 -67
- package/dist/esm/frontendViteConfig.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js +774 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/handler.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js +746 -0
- package/dist/esm/node_modules/.pnpm/chokidar@5.0.0/node_modules/chokidar/index.js.map +1 -0
- package/dist/esm/node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js +241 -0
- package/dist/esm/node_modules/.pnpm/readdirp@5.0.0/node_modules/readdirp/index.js.map +1 -0
- package/dist/esm/watchExternalSource.d.ts +69 -0
- package/dist/esm/watchExternalSource.js +85 -0
- package/dist/esm/watchExternalSource.js.map +1 -0
- package/package.json +10 -6
- package/src/frontendViteConfig.ts +163 -70
- package/src/index.ts +6 -0
- package/src/watchExternalSource.ts +177 -0
|
@@ -1,12 +1,36 @@
|
|
|
1
|
-
|
|
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
|
+
}): {
|
|
2
10
|
server: {
|
|
3
11
|
port: number;
|
|
4
12
|
strictPort: true;
|
|
5
13
|
host: string;
|
|
6
14
|
proxy: {
|
|
7
|
-
'/
|
|
8
|
-
|
|
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
|
+
};
|
|
9
29
|
};
|
|
10
30
|
};
|
|
11
|
-
|
|
31
|
+
resolve: {
|
|
32
|
+
conditions: string[];
|
|
33
|
+
};
|
|
34
|
+
publicDir: string;
|
|
35
|
+
plugins: import('vite').PluginOption[];
|
|
12
36
|
};
|
|
@@ -1,81 +1,148 @@
|
|
|
1
|
-
import * as process from "node:process";
|
|
2
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";
|
|
3
5
|
import { VitePWA } from "vite-plugin-pwa";
|
|
6
|
+
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
4
7
|
import svgr from "vite-plugin-svgr";
|
|
5
|
-
function frontendViteConfig() {
|
|
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/@env-hopper/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
|
+
"env-hopper-*.png",
|
|
43
|
+
"env-hopper-square.svg"
|
|
44
|
+
],
|
|
45
|
+
manifest: {
|
|
46
|
+
name: "Env Hopper",
|
|
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: "env-hopper-16x16.png",
|
|
61
|
+
sizes: "16x16",
|
|
62
|
+
type: "image/png"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
src: "env-hopper-32x32.png",
|
|
66
|
+
sizes: "32x32",
|
|
67
|
+
type: "image/png"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
src: "env-hopper-48x48.png",
|
|
71
|
+
sizes: "48x48",
|
|
72
|
+
type: "image/png"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
src: "env-hopper-192x192.png",
|
|
76
|
+
sizes: "192x192",
|
|
77
|
+
type: "image/png"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
src: "env-hopper-512x512.png",
|
|
81
|
+
sizes: "512x512",
|
|
82
|
+
type: "image/png"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
src: "env-hopper-square.svg",
|
|
86
|
+
sizes: "150x150",
|
|
87
|
+
type: "image/svg+xml"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
src: "env-hopper-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
|
+
}
|
|
6
117
|
return {
|
|
7
118
|
server: {
|
|
8
119
|
port: 4e3,
|
|
9
120
|
strictPort: true,
|
|
10
121
|
host: "localhost",
|
|
11
122
|
proxy: {
|
|
12
|
-
"/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// registerType:
|
|
26
|
-
// env['VITE_AUTO_UPDATE'] === 'true' ? 'autoUpdate' : 'prompt',
|
|
27
|
-
// selfDestroying: env['SELF_DESTROYING'] === 'true' ? true : undefined,
|
|
28
|
-
includeAssets: ["favicon.ico", "*.svg"],
|
|
29
|
-
manifest: {
|
|
30
|
-
name: "Env hopper",
|
|
31
|
-
short_name: "EH",
|
|
32
|
-
description: "Jump between environments",
|
|
33
|
-
theme_color: "#1f2937",
|
|
34
|
-
icons: [
|
|
35
|
-
{
|
|
36
|
-
src: "favicon.ico",
|
|
37
|
-
sizes: "48x48"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
src: "env-hopper-square.svg",
|
|
41
|
-
sizes: "150x150"
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
src: "env-hopper-square.svg",
|
|
45
|
-
sizes: "150x150",
|
|
46
|
-
purpose: "maskable"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
src: "env-hopper-512x512.png",
|
|
50
|
-
sizes: "512x512",
|
|
51
|
-
type: "image/png"
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
}),
|
|
56
|
-
svgr(),
|
|
57
|
-
// TanStackRouterVite(),
|
|
58
|
-
viteReact(),
|
|
59
|
-
process.env["NODE_ENV"] === "test" && {
|
|
60
|
-
name: "load-svg",
|
|
61
|
-
enforce: "pre",
|
|
62
|
-
transform(_, id) {
|
|
63
|
-
if (id.endsWith(".svg?react")) {
|
|
64
|
-
return `export default () => "svg-stub"`;
|
|
65
|
-
}
|
|
66
|
-
return void 0;
|
|
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
|
|
67
136
|
}
|
|
68
137
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// },
|
|
78
|
-
// },
|
|
138
|
+
},
|
|
139
|
+
resolve: {
|
|
140
|
+
// Use 'my-custom-condition' to resolve @env-hopper/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
|
|
79
146
|
};
|
|
80
147
|
}
|
|
81
148
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontendViteConfig.js","sources":["../../src/frontendViteConfig.ts"],"sourcesContent":["import * as process from 'node:process'\nimport
|
|
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/@env-hopper/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 'env-hopper-*.png',\n 'env-hopper-square.svg',\n ],\n manifest: {\n name: 'Env Hopper',\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: 'env-hopper-16x16.png',\n sizes: '16x16',\n type: 'image/png',\n },\n {\n src: 'env-hopper-32x32.png',\n sizes: '32x32',\n type: 'image/png',\n },\n {\n src: 'env-hopper-48x48.png',\n sizes: '48x48',\n type: 'image/png',\n },\n {\n src: 'env-hopper-192x192.png',\n sizes: '192x192',\n type: 'image/png',\n },\n {\n src: 'env-hopper-512x512.png',\n sizes: '512x512',\n type: 'image/png',\n },\n {\n src: 'env-hopper-square.svg',\n sizes: '150x150',\n type: 'image/svg+xml',\n },\n {\n src: 'env-hopper-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 @env-hopper/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,Q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ACH;AAIA,SAAO;AAAA,IACL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,YAAY;AAAA,MACZ,MAAM;AAAA,MACN,OAAO;AAAA,QACL,QAAQ;AAAA,UACN,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,qBAAqB;AAAA,QAAA;AAAA,QAEvB,SAAS;AAAA,UACP,QAAQ;AAAA,UACR,cAAc;AAAA,UACd,qBAAqB;AAAA,QAAA;AAAA,QAEvB,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;"}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { frontendViteConfig } from "./frontendViteConfig.js";
|
|
2
|
+
import { createFsAllowPaths, createSourceAliases, watchExternalSource } from "./watchExternalSource.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
+
createFsAllowPaths,
|
|
5
|
+
createSourceAliases,
|
|
6
|
+
frontendViteConfig,
|
|
7
|
+
watchExternalSource
|
|
4
8
|
};
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|