@lomray/vite-ssr-boost 1.0.0-beta.6 → 1.0.0-beta.8
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/README.md +207 -0
- package/cli/build.d.ts +3 -1
- package/cli/build.js +1 -1
- package/cli/build.js.map +1 -1
- package/cli/run-docker-build.d.ts +12 -0
- package/cli/run-docker-build.js +2 -0
- package/cli/run-docker-build.js.map +1 -0
- package/cli/run-prod.js +1 -1
- package/cli/run-prod.js.map +1 -1
- package/cli.js +1 -1
- package/cli.js.map +1 -1
- package/constants/cli-actions.d.ts +1 -0
- package/constants/cli-actions.js +1 -1
- package/constants/cli-actions.js.map +1 -1
- package/helpers/dev-marker.d.ts +9 -0
- package/helpers/dev-marker.js +2 -0
- package/helpers/dev-marker.js.map +1 -0
- package/helpers/print-server-info.js +1 -1
- package/helpers/print-server-info.js.map +1 -1
- package/helpers/print-server-urls.js +1 -1
- package/helpers/print-server-urls.js.map +1 -1
- package/helpers/unlock-robots.d.ts +5 -0
- package/helpers/unlock-robots.js +2 -0
- package/helpers/unlock-robots.js.map +1 -0
- package/package.json +1 -1
- package/plugins/normalize-route.js +1 -1
- package/plugins/normalize-route.js.map +1 -1
- package/workflow/Dockerfile +24 -0
package/README.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
<h1 align='center'>Vite SSR BOOST</h1>
|
|
2
|
+
|
|
3
|
+
- Develop ⚡charged⚡ server side applications with React streaming 💨 support.
|
|
4
|
+
- Unlocks Suspense for server side applications.
|
|
5
|
+
- Switch between SPA and SSR in 1 second.
|
|
6
|
+
- Charged CLI out of box.
|
|
7
|
+
- Very easy to migrate, very easy to use.
|
|
8
|
+
- All the power of [vite](https://vitejs.dev/)⚡
|
|
9
|
+
- All the power of [react-router](https://reactrouter.com/)🛣
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=reliability_rating" alt="reliability">
|
|
13
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=security_rating" alt="Security Rating">
|
|
14
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=sqale_rating" alt="Maintainability Rating">
|
|
15
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=vulnerabilities" alt="Vulnerabilities">
|
|
16
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=bugs" alt="Bugs">
|
|
17
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=vite-ssr-boost&metric=ncloc" alt="Lines of Code">
|
|
18
|
+
<img src="https://img.shields.io/bundlephobia/minzip/@lomray/vite-ssr-boost" alt="size">
|
|
19
|
+
<img src="https://img.shields.io/npm/l/@lomray/vite-ssr-boost" alt="size">
|
|
20
|
+
<img src="https://img.shields.io/npm/v/@lomray/vite-ssr-boost?label=semantic%20release&logo=semantic-release" alt="semantic version">
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
## Table of contents
|
|
24
|
+
- [Getting started](#getting-started)
|
|
25
|
+
- [How to use](#how-to-use)
|
|
26
|
+
- [Plugin options](#plugin-options)
|
|
27
|
+
- [CLI](#cli)
|
|
28
|
+
- [Example](#demo)
|
|
29
|
+
- [Bugs and feature requests](#bugs-and-feature-requests)
|
|
30
|
+
- [License](#license)
|
|
31
|
+
|
|
32
|
+
## Getting started
|
|
33
|
+
|
|
34
|
+
The package is distributed using [npm](https://www.npmjs.com/), the node package manager.
|
|
35
|
+
|
|
36
|
+
```
|
|
37
|
+
npm i --save @lomray/vite-ssr-boost
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## How to use
|
|
41
|
+
|
|
42
|
+
1. Add plugin to vite config:
|
|
43
|
+
```typescript
|
|
44
|
+
/**
|
|
45
|
+
* vite.config.ts
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
import { defineConfig } from 'vite'
|
|
49
|
+
import react from '@vitejs/plugin-react'
|
|
50
|
+
/**
|
|
51
|
+
* Import plugin
|
|
52
|
+
*/
|
|
53
|
+
import SsrBoost from '@lomray/vite-ssr-boost/plugin';
|
|
54
|
+
|
|
55
|
+
// https://vitejs.dev/config/
|
|
56
|
+
export default defineConfig({
|
|
57
|
+
/**
|
|
58
|
+
* Change root not necessary, but more understandable
|
|
59
|
+
*/
|
|
60
|
+
root: 'src',
|
|
61
|
+
publicDir: '../public',
|
|
62
|
+
build: {
|
|
63
|
+
outDir: '../build',
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Put here
|
|
67
|
+
*/
|
|
68
|
+
plugins: [SsrBoost(), react()],
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
2. Create `client` entrypoint:
|
|
73
|
+
|
|
74
|
+
```typescript jsx
|
|
75
|
+
/**
|
|
76
|
+
* src/client.tsx
|
|
77
|
+
*/
|
|
78
|
+
import entryClient from '@lomray/vite-ssr-boost/browser/entry';
|
|
79
|
+
import App from './App.tsx'
|
|
80
|
+
import routes from './routes';
|
|
81
|
+
|
|
82
|
+
void entryClient(App, routes, {
|
|
83
|
+
/**
|
|
84
|
+
* Client configuration (optional)
|
|
85
|
+
*/
|
|
86
|
+
init: () => {}
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
3. Create `server` entrypoint:
|
|
91
|
+
|
|
92
|
+
```typescript jsx
|
|
93
|
+
/**
|
|
94
|
+
* src/server.ts
|
|
95
|
+
*/
|
|
96
|
+
import entryServer from '@lomray/vite-ssr-boost/node/entry';
|
|
97
|
+
import App from './App';
|
|
98
|
+
import routes from './routes';
|
|
99
|
+
|
|
100
|
+
export default entryServer(App, routes, {
|
|
101
|
+
/**
|
|
102
|
+
* Server configuration (optional)
|
|
103
|
+
*/
|
|
104
|
+
init: () => ({
|
|
105
|
+
/**
|
|
106
|
+
* (optional). Called once after express server creation.
|
|
107
|
+
* E.g. use for configure express middlewares
|
|
108
|
+
*/
|
|
109
|
+
onServerCreated: () => {},
|
|
110
|
+
/**
|
|
111
|
+
* (optional). Called on each incoming request.
|
|
112
|
+
* E.g. configure request state, create state manager etc.
|
|
113
|
+
*/
|
|
114
|
+
onRequest: async () => {},
|
|
115
|
+
/**
|
|
116
|
+
* (optional). Called when react router and it's context was created.
|
|
117
|
+
* E.g. here you can switch stream depends on req.headers, for search crawlers you can disable stream.
|
|
118
|
+
*/
|
|
119
|
+
onRouterReady: () => {},
|
|
120
|
+
/**
|
|
121
|
+
* (optional). Called when application shell is ready to send on client.
|
|
122
|
+
* E.g. here you can modify header or footer.
|
|
123
|
+
*/
|
|
124
|
+
onShellReady: () => {},
|
|
125
|
+
/**
|
|
126
|
+
* (optional). Called when application shell or suspense resolved and sent to the client.
|
|
127
|
+
* E.g. here you can add some payload like custom state (any manager state) to response.
|
|
128
|
+
*/
|
|
129
|
+
onResponse: () => {},
|
|
130
|
+
/**
|
|
131
|
+
* (optional). Called when application shell or all html (depends on stream option) is ready to send on client.
|
|
132
|
+
* E.g. here you can send any context or state to client.
|
|
133
|
+
*/
|
|
134
|
+
getState: () => {},
|
|
135
|
+
}),
|
|
136
|
+
}, App);
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
4. Replace `package.json` scripts:
|
|
140
|
+
|
|
141
|
+
```json
|
|
142
|
+
{
|
|
143
|
+
...
|
|
144
|
+
"scripts": {
|
|
145
|
+
"develop": "ssr-boost dev",
|
|
146
|
+
"build": "ssr-boost build",
|
|
147
|
+
"start:ssr": "ssr-boost start",
|
|
148
|
+
"start:spa": "ssr-boost start --only-client",
|
|
149
|
+
"preview": "ssr-boost preview"
|
|
150
|
+
},
|
|
151
|
+
...
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
5. Let's do the magic:
|
|
156
|
+
|
|
157
|
+
```shell
|
|
158
|
+
npm run develop
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Plugin options
|
|
162
|
+
```typescript
|
|
163
|
+
import SsrBoost from '@lomray/vite-ssr-boost/plugin';
|
|
164
|
+
import type { FCRoute } from '@lomray/vite-ssr-boost/interfaces/fc-route';
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Configuration
|
|
168
|
+
*/
|
|
169
|
+
SsrBoost({
|
|
170
|
+
/**
|
|
171
|
+
* With this option you can export route components like FCRoute or FCCRoute
|
|
172
|
+
* @example
|
|
173
|
+
* const Page: FCRoute = () => <div>Hi</div>;
|
|
174
|
+
*
|
|
175
|
+
* Page.ErrorBoudary = () => <div>Error</div>;
|
|
176
|
+
*
|
|
177
|
+
* export default Page;
|
|
178
|
+
*
|
|
179
|
+
* Routes:
|
|
180
|
+
* const routes = [{ path: '/', lazyNR: () => import('./pages/home') }]
|
|
181
|
+
*/
|
|
182
|
+
hasLazyRoutePlugin: true, // default: true
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Add tsconfig aliases to vite config aliases
|
|
186
|
+
*/
|
|
187
|
+
tsconfigAliases: true, // default: true
|
|
188
|
+
})
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## CLI
|
|
192
|
+
Explore all commands and options:
|
|
193
|
+
```shell
|
|
194
|
+
ssr-boost -h
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Demo
|
|
198
|
+
Explore [demo app](https://github.com/Lomray-Software/vite-template) to more understand.
|
|
199
|
+
|
|
200
|
+
## Bugs and feature requests
|
|
201
|
+
|
|
202
|
+
Bug or a feature request, [please open a new issue](https://github.com/Lomray-Software/vite-ssr-boost/issues/new).
|
|
203
|
+
|
|
204
|
+
## License
|
|
205
|
+
Made with 💚
|
|
206
|
+
|
|
207
|
+
Published under [Apache License](./LICENSE).
|
package/cli/build.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
interface IBuildParams {
|
|
2
2
|
isOnlyClient?: boolean;
|
|
3
3
|
isWatch?: boolean;
|
|
4
|
+
isUnlockRobots?: boolean;
|
|
4
5
|
clientOptions?: string;
|
|
5
6
|
serverOptions?: string;
|
|
6
7
|
mode?: string;
|
|
8
|
+
onFinish?: () => void;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Build production application
|
|
10
12
|
*/
|
|
11
|
-
declare function build({ isOnlyClient, isWatch, clientOptions, serverOptions, mode, }: IBuildParams): Promise<void
|
|
13
|
+
declare function build({ onFinish, isOnlyClient, isWatch, isUnlockRobots, clientOptions, serverOptions, mode, }: IBuildParams): Promise<void>;
|
|
12
14
|
export { build as default };
|
package/cli/build.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"node:child_process";import e from"node:fs";import t from"node:path";import{performance as r}from"node:perf_hooks";import s from"chalk";import{resolveConfig as i}from"vite";import n from"./vite-reset-cache.js";import p from"../constants/cli-name.js";import{createDevMarker as c}from"../helpers/dev-marker.js";import d from"../helpers/plugin-config.js";import m from"../helpers/unlock-robots.js";const l=o=>{const e=new Promise(((e,t)=>{o.on("exit",(o=>{e(o)})),o.on("close",(o=>{e(o)})),o.on("error",(o=>{t(o)}))}));return o.stdout?.pipe(process.stdout),o.stderr?.pipe(process.stderr),e.command=o,e};async function a({onFinish:a,isOnlyClient:u=!1,isWatch:f=!1,isUnlockRobots:v=!1,clientOptions:O="",serverOptions:h="",mode:S=""}){const $=r.now(),b=await i({},"build",S,"production"===S?"production":"development"),_=d(b),{outDir:w}=b.build,g=["client"],R=new AbortController,y=S?`--mode ${S}`:"",C=process.env.NODE_ENV||"development",D="production"===C,j=t.resolve(b.root,w);await n(),e.existsSync(j)&&e.rmSync(j,{recursive:!0});const E=l(o.spawn(`vite build ${O} --emptyOutDir --outDir ${w}/client ${y}`,{signal:R.signal,stdio:[process.stdin,"pipe",process.stderr],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:u?"0":"1"}}));let k;if(f||await E,u||(k=l(o.spawn(`vite build ${h} --emptyOutDir --outDir ${w}/server --ssr ${_.serverFile} ${y}`,{signal:R.signal,stdio:[process.stdin,"pipe",process.stderr],shell:!0,env:{...process.env,FORCE_COLOR:"2",SSR_BOOST_IS_SSR:u?"0":"1"}})),f||await k,g.push("server")),f){process.on("exit",(()=>{R.abort()}));let o=u?1:2;const e=t=>{Buffer.from(t).toString().includes("built in")&&(o-=1,o||(E.command.stdout.removeListener("data",e),k?.command.stdout.removeListener("data",e),c(D,b),a?.()))};return E.command.stdout.on("data",e),void k?.command.stdout.on("data",e)}v&&m(b.root,w),c(D,b),a?.();const B=s.dim(`${s.yellowBright(g.join(","))} built in ${s.reset(s.bold(Math.ceil(r.now()-$)))} ms`);console.info(`\n ${s.green(`${s.bold(p.toUpperCase())}`)} ${B} ${D?"":s.redBright(`NODE_ENV=${C}`)}\n`)}export{a as default};
|
|
2
2
|
//# sourceMappingURL=build.js.map
|
package/cli/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["../../src/cli/build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport cliName from '@constants/cli-name';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IBuildParams {\n isOnlyClient?: boolean;\n isWatch?: boolean;\n clientOptions?: string;\n serverOptions?: string;\n mode?: string;\n}\n\n/**\n * Promisify spawn process\n */\nconst promisify = (command: childProcess.ChildProcess)
|
|
1
|
+
{"version":3,"file":"build.js","sources":["../../src/cli/build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport { resolveConfig } from 'vite';\nimport viteResetCache from '@cli/vite-reset-cache';\nimport cliName from '@constants/cli-name';\nimport { createDevMarker } from '@helpers/dev-marker';\nimport getPluginConfig from '@helpers/plugin-config';\nimport unlockRobots from '@helpers/unlock-robots';\n\ninterface IBuildParams {\n isOnlyClient?: boolean;\n isWatch?: boolean;\n isUnlockRobots?: boolean;\n clientOptions?: string;\n serverOptions?: string;\n mode?: string;\n onFinish?: () => void;\n}\n\n/**\n * Promisify spawn process\n */\nconst promisify = (command: childProcess.ChildProcess) => {\n const promise = new Promise((resolve, reject) => {\n command.on('exit', (code) => {\n resolve(code);\n });\n\n command.on('close', (code) => {\n resolve(code);\n });\n\n command.on('error', (message) => {\n reject(message);\n });\n });\n\n command.stdout?.pipe(process.stdout);\n command.stderr?.pipe(process.stderr);\n\n promise['command'] = command;\n\n return promise;\n};\n\n/**\n * Build production application\n */\nasync function build({\n onFinish,\n isOnlyClient = false,\n isWatch = false,\n isUnlockRobots = false,\n clientOptions = '',\n serverOptions = '',\n mode = '',\n}: IBuildParams): Promise<void> {\n const perfStart = performance.now();\n const config = await resolveConfig(\n {},\n 'build',\n mode,\n mode === 'production' ? 'production' : 'development',\n );\n const pluginConfig = getPluginConfig(config);\n const { outDir } = config.build;\n const types = ['client'];\n const controller = new AbortController();\n const modeOpt = mode ? `--mode ${mode}` : '';\n const nodeEnv = process.env.NODE_ENV || 'development';\n const isProd = nodeEnv === 'production';\n const buildDir = path.resolve(config.root, outDir);\n\n // this is required step - build with different env may cause problems\n await viteResetCache();\n\n // clear build folder\n if (fs.existsSync(buildDir)) {\n fs.rmSync(buildDir, { recursive: true });\n }\n\n /**\n * Build client\n */\n const clientProcess = promisify(\n childProcess.spawn(\n `vite build ${clientOptions} --emptyOutDir --outDir ${outDir}/client ${modeOpt}`,\n {\n signal: controller.signal,\n stdio: [process.stdin, 'pipe', process.stderr],\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n },\n },\n ),\n );\n\n if (!isWatch) {\n await clientProcess;\n }\n\n let serverProcess: Promise<unknown> | undefined;\n\n /**\n * Build server\n */\n if (!isOnlyClient) {\n serverProcess = promisify(\n childProcess.spawn(\n `vite build ${serverOptions} --emptyOutDir --outDir ${outDir}/server --ssr ${pluginConfig.serverFile} ${modeOpt}`,\n {\n signal: controller.signal,\n stdio: [process.stdin, 'pipe', process.stderr],\n shell: true,\n env: {\n ...process.env,\n FORCE_COLOR: '2',\n SSR_BOOST_IS_SSR: isOnlyClient ? '0' : '1',\n },\n },\n ),\n );\n\n if (!isWatch) {\n await serverProcess;\n }\n\n types.push('server');\n }\n\n /**\n * Preview mode\n */\n if (isWatch) {\n process.on('exit', () => {\n controller.abort();\n });\n\n let buildCount = isOnlyClient ? 1 : 2;\n const listener = (buff: Uint8Array): void => {\n const msg = Buffer.from(buff).toString();\n\n if (msg.includes('built in')) {\n buildCount -= 1;\n\n if (!buildCount) {\n clientProcess['command'].stdout.removeListener('data', listener);\n serverProcess?.['command'].stdout.removeListener('data', listener);\n createDevMarker(isProd, config);\n onFinish?.();\n }\n }\n };\n\n /**\n * Listen output for call onFinish\n */\n clientProcess['command'].stdout.on('data', listener);\n serverProcess?.['command'].stdout.on('data', listener);\n\n return;\n }\n\n if (isUnlockRobots) {\n unlockRobots(config.root, outDir);\n }\n\n createDevMarker(isProd, config);\n onFinish?.();\n\n const buildDurationString = chalk.dim(\n `${chalk.yellowBright(types.join(','))} built in ${chalk.reset(\n chalk.bold(Math.ceil(performance.now() - perfStart)),\n )} ms`,\n );\n\n console.info(\n `\\n ${chalk.green(`${chalk.bold(cliName.toUpperCase())}`)} ${buildDurationString} ${\n isProd ? '' : chalk.redBright(`NODE_ENV=${nodeEnv}`)\n }\\n`,\n );\n}\n\nexport default build;\n"],"names":["promisify","command","promise","Promise","resolve","reject","on","code","message","stdout","pipe","process","stderr","async","build","onFinish","isOnlyClient","isWatch","isUnlockRobots","clientOptions","serverOptions","mode","perfStart","performance","now","config","resolveConfig","pluginConfig","getPluginConfig","outDir","types","controller","AbortController","modeOpt","nodeEnv","env","NODE_ENV","isProd","buildDir","path","root","viteResetCache","fs","existsSync","rmSync","recursive","clientProcess","childProcess","spawn","signal","stdio","stdin","shell","FORCE_COLOR","SSR_BOOST_IS_SSR","serverProcess","serverFile","push","abort","buildCount","listener","buff","Buffer","from","toString","includes","removeListener","createDevMarker","unlockRobots","buildDurationString","chalk","dim","yellowBright","join","reset","bold","Math","ceil","console","info","green","cliName","toUpperCase","redBright"],"mappings":"wZAyBA,MAAMA,EAAaC,IACjB,MAAMC,EAAU,IAAIC,SAAQ,CAACC,EAASC,KACpCJ,EAAQK,GAAG,QAASC,IAClBH,EAAQG,EAAK,IAGfN,EAAQK,GAAG,SAAUC,IACnBH,EAAQG,EAAK,IAGfN,EAAQK,GAAG,SAAUE,IACnBH,EAAOG,EAAQ,GACf,IAQJ,OALAP,EAAQQ,QAAQC,KAAKC,QAAQF,QAC7BR,EAAQW,QAAQF,KAAKC,QAAQC,QAE7BV,EAAiB,QAAID,EAEdC,CAAO,EAMhBW,eAAeC,GAAMC,SACnBA,EAAQC,aACRA,GAAe,EAAKC,QACpBA,GAAU,EAAKC,eACfA,GAAiB,EAAKC,cACtBA,EAAgB,GAAEC,cAClBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAYC,EAAYC,MACxBC,QAAeC,EACnB,CAAA,EACA,QACAL,EACS,eAATA,EAAwB,aAAe,eAEnCM,EAAeC,EAAgBH,IAC/BI,OAAEA,GAAWJ,EAAOX,MACpBgB,EAAQ,CAAC,UACTC,EAAa,IAAIC,gBACjBC,EAAUZ,EAAO,UAAUA,IAAS,GACpCa,EAAUvB,QAAQwB,IAAIC,UAAY,cAClCC,EAAqB,eAAZH,EACTI,EAAWC,EAAKnC,QAAQqB,EAAOe,KAAMX,SAGrCY,IAGFC,EAAGC,WAAWL,IAChBI,EAAGE,OAAON,EAAU,CAAEO,WAAW,IAMnC,MAAMC,EAAgB9C,EACpB+C,EAAaC,MACX,cAAc7B,4BAAwCU,YAAiBI,IACvE,CACEgB,OAAQlB,EAAWkB,OACnBC,MAAO,CAACvC,QAAQwC,MAAO,OAAQxC,QAAQC,QACvCwC,OAAO,EACPjB,IAAK,IACAxB,QAAQwB,IACXkB,YAAa,IACbC,iBAAkBtC,EAAe,IAAM,QAU/C,IAAIuC,EAgCJ,GApCKtC,SACG6B,EAQH9B,IACHuC,EAAgBvD,EACd+C,EAAaC,MACX,cAAc5B,4BAAwCS,kBAAuBF,EAAa6B,cAAcvB,IACxG,CACEgB,OAAQlB,EAAWkB,OACnBC,MAAO,CAACvC,QAAQwC,MAAO,OAAQxC,QAAQC,QACvCwC,OAAO,EACPjB,IAAK,IACAxB,QAAQwB,IACXkB,YAAa,IACbC,iBAAkBtC,EAAe,IAAM,QAM1CC,SACGsC,EAGRzB,EAAM2B,KAAK,WAMTxC,EAAS,CACXN,QAAQL,GAAG,QAAQ,KACjByB,EAAW2B,OAAO,IAGpB,IAAIC,EAAa3C,EAAe,EAAI,EACpC,MAAM4C,EAAYC,IACJC,OAAOC,KAAKF,GAAMG,WAEtBC,SAAS,cACfN,GAAc,EAETA,IACHb,EAAuB,QAAErC,OAAOyD,eAAe,OAAQN,GACvDL,GAAyB,QAAE9C,OAAOyD,eAAe,OAAQN,GACzDO,EAAgB9B,EAAQZ,GACxBV,OAEH,EASH,OAHA+B,EAAuB,QAAErC,OAAOH,GAAG,OAAQsD,QAC3CL,GAAyB,QAAE9C,OAAOH,GAAG,OAAQsD,EAG9C,CAEG1C,GACFkD,EAAa3C,EAAOe,KAAMX,GAG5BsC,EAAgB9B,EAAQZ,GACxBV,MAEA,MAAMsD,EAAsBC,EAAMC,IAChC,GAAGD,EAAME,aAAa1C,EAAM2C,KAAK,kBAAkBH,EAAMI,MACvDJ,EAAMK,KAAKC,KAAKC,KAAKtD,EAAYC,MAAQF,WAI7CwD,QAAQC,KACN,OAAOT,EAAMU,MAAM,GAAGV,EAAMK,KAAKM,EAAQC,sBAAsBb,KAC7DhC,EAAS,GAAKiC,EAAMa,UAAU,YAAYjD,SAGhD"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface IRunDockerBuildParams {
|
|
2
|
+
imageName: string;
|
|
3
|
+
dockerOptions?: string;
|
|
4
|
+
dockerFile?: string;
|
|
5
|
+
isOnlyClient?: boolean;
|
|
6
|
+
mode?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Build docker image
|
|
10
|
+
*/
|
|
11
|
+
declare function runDockerBuild({ imageName, dockerFile, isOnlyClient, dockerOptions, mode, }: IRunDockerBuildParams): Promise<void>;
|
|
12
|
+
export { runDockerBuild as default };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from"node:child_process";import e from"node:path";import{cwd as r}from"node:process";import{resolveConfig as i}from"vite";import t from"../helpers/plugin-config.js";async function d({imageName:d,dockerFile:l,isOnlyClient:n=!1,dockerOptions:p="",mode:s=""}){const c="production"===s?"production":"development",a=await i({},"build",s),m=t(a),{root:u,build:{outDir:f}}=a,$=r(),g=`.${e.resolve(u,f).replace($,"")}`,b=n?"spa":"ssr",h=l||`${m.pluginPath}/workflow/Dockerfile`;o.execSync(`docker build -f ${h} --build-arg ROOT_PATH=${$} --build-arg BUILD_PATH=${g} --build-arg RUN_TYPE=${b} --build-arg ENV_MODE=${c}${p} -t ${d} ${$}`,{stdio:"inherit",env:{...process.env}})}export{d as default};
|
|
2
|
+
//# sourceMappingURL=run-docker-build.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-docker-build.js","sources":["../../src/cli/run-docker-build.ts"],"sourcesContent":["import childProcess from 'node:child_process';\nimport path from 'node:path';\nimport { cwd } from 'node:process';\nimport { resolveConfig } from 'vite';\nimport getPluginConfig from '@helpers/plugin-config';\n\ninterface IRunDockerBuildParams {\n imageName: string;\n dockerOptions?: string;\n dockerFile?: string;\n isOnlyClient?: boolean;\n mode?: string;\n}\n\n/**\n * Build docker image\n */\nasync function runDockerBuild({\n imageName,\n dockerFile,\n isOnlyClient = false,\n dockerOptions = '',\n mode = '',\n}: IRunDockerBuildParams): Promise<void> {\n const nodeEnv = mode === 'production' ? 'production' : 'development';\n const config = await resolveConfig({}, 'build', mode);\n const pluginConfig = getPluginConfig(config);\n const {\n root,\n build: { outDir },\n } = config;\n const projectRoot = cwd();\n const buildDir = `.${path.resolve(root, outDir).replace(projectRoot, '')}`; // relative path\n const runType = isOnlyClient ? 'spa' : 'ssr';\n const docFile = dockerFile || `${pluginConfig.pluginPath}/workflow/Dockerfile`;\n\n childProcess.execSync(\n `docker build -f ${docFile}` +\n ` --build-arg ROOT_PATH=${projectRoot} --build-arg BUILD_PATH=${buildDir}` +\n ` --build-arg RUN_TYPE=${runType} --build-arg ENV_MODE=${nodeEnv}` +\n `${dockerOptions} -t ${imageName} ${projectRoot}`,\n {\n stdio: 'inherit',\n env: {\n ...process.env,\n },\n },\n );\n}\n\nexport default runDockerBuild;\n"],"names":["async","runDockerBuild","imageName","dockerFile","isOnlyClient","dockerOptions","mode","nodeEnv","config","resolveConfig","pluginConfig","getPluginConfig","root","build","outDir","projectRoot","cwd","buildDir","path","resolve","replace","runType","docFile","pluginPath","childProcess","execSync","stdio","env","process"],"mappings":"8KAiBAA,eAAeC,GAAeC,UAC5BA,EAASC,WACTA,EAAUC,aACVA,GAAe,EAAKC,cACpBA,EAAgB,GAAEC,KAClBA,EAAO,KAEP,MAAMC,EAAmB,eAATD,EAAwB,aAAe,cACjDE,QAAeC,EAAc,CAAE,EAAE,QAASH,GAC1CI,EAAeC,EAAgBH,IAC/BI,KACJA,EACAC,OAAOC,OAAEA,IACPN,EACEO,EAAcC,IACdC,EAAW,IAAIC,EAAKC,QAAQP,EAAME,GAAQM,QAAQL,EAAa,MAC/DM,EAAUjB,EAAe,MAAQ,MACjCkB,EAAUnB,GAAc,GAAGO,EAAaa,iCAE9CC,EAAaC,SACX,mBAAmBH,2BACSP,4BAAsCE,0BACvCI,0BAAgCd,IACtDF,QAAoBH,KAAaa,IACtC,CACEW,MAAO,UACPC,IAAK,IACAC,QAAQD,MAInB"}
|
package/cli/run-prod.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{performance as o}from"node:perf_hooks";import r from"../node/server.js";import i from"../services/server-config.js";async function
|
|
1
|
+
import{performance as o}from"node:perf_hooks";import r from"../node/server.js";import i from"../services/server-config.js";async function t({version:t,isHost:s,isPrintInfo:e,port:n,onlyClient:f=!1}){global.viteBoostStartTime||(global.viteBoostStartTime=o.now());const a=i.init({isHost:s,isProd:!0,isOnlyClient:f},{port:n}),{run:l}=await r(a);return{server:l({version:t,isPrintInfo:e}),config:a}}export{t as default};
|
|
2
2
|
//# sourceMappingURL=run-prod.js.map
|
package/cli/run-prod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-prod.js","sources":["../../src/cli/run-prod.ts"],"sourcesContent":["import type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport createServer from '@node/server';\nimport ServerConfig from '@services/server-config';\n\ninterface IRunProdParams {\n version: string;\n port?: number;\n isHost?: boolean;\n isPrintInfo?: boolean;\n onlyClient?: boolean; // SPA mode\n mode?: string;\n}\n\ninterface IRunProdOut {\n server: Server;\n config: ServerConfig;\n}\n\n/**\n * Run production server\n */\nasync function runProd({\n version,\n isHost,\n isPrintInfo,\n port,\n onlyClient = false,\n}: IRunProdParams): Promise<IRunProdOut> {\n global.viteBoostStartTime = performance.now();\n\n const config = ServerConfig.init({ isHost, isProd: true, isOnlyClient: onlyClient }, { port });\n const { run } = await createServer(config);\n\n return {\n server: run({ version, isPrintInfo }),\n config,\n };\n}\n\nexport default runProd;\n"],"names":["async","runProd","version","isHost","isPrintInfo","port","onlyClient","global","viteBoostStartTime","performance","now","config","ServerConfig","init","isProd","isOnlyClient","run","createServer","server"],"mappings":"2HAsBAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,WACJA,GAAa,
|
|
1
|
+
{"version":3,"file":"run-prod.js","sources":["../../src/cli/run-prod.ts"],"sourcesContent":["import type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport createServer from '@node/server';\nimport ServerConfig from '@services/server-config';\n\ninterface IRunProdParams {\n version: string;\n port?: number;\n isHost?: boolean;\n isPrintInfo?: boolean;\n onlyClient?: boolean; // SPA mode\n mode?: string;\n}\n\ninterface IRunProdOut {\n server: Server;\n config: ServerConfig;\n}\n\n/**\n * Run production server\n */\nasync function runProd({\n version,\n isHost,\n isPrintInfo,\n port,\n onlyClient = false,\n}: IRunProdParams): Promise<IRunProdOut> {\n if (!global.viteBoostStartTime) {\n global.viteBoostStartTime = performance.now();\n }\n\n const config = ServerConfig.init({ isHost, isProd: true, isOnlyClient: onlyClient }, { port });\n const { run } = await createServer(config);\n\n return {\n server: run({ version, isPrintInfo }),\n config,\n };\n}\n\nexport default runProd;\n"],"names":["async","runProd","version","isHost","isPrintInfo","port","onlyClient","global","viteBoostStartTime","performance","now","config","ServerConfig","init","isProd","isOnlyClient","run","createServer","server"],"mappings":"2HAsBAA,eAAeC,GAAQC,QACrBA,EAAOC,OACPA,EAAMC,YACNA,EAAWC,KACXA,EAAIC,WACJA,GAAa,IAERC,OAAOC,qBACVD,OAAOC,mBAAqBC,EAAYC,OAG1C,MAAMC,EAASC,EAAaC,KAAK,CAAEV,SAAQW,QAAQ,EAAMC,aAAcT,GAAc,CAAED,UACjFW,IAAEA,SAAcC,EAAaN,GAEnC,MAAO,CACLO,OAAQF,EAAI,CAAEd,UAASE,gBACvBO,SAEJ"}
|
package/cli.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as o}from"fs";import e from"chalk";import{Command as n,Option as
|
|
2
|
+
import{readFileSync as o}from"fs";import e from"chalk";import{Command as n,Option as i}from"commander";import t from"./cli/build.js";import r from"./cli/keyboard-input.js";import s from"./cli/run-dev.js";import a from"./cli/run-docker-build.js";import d from"./cli/run-prod.js";import c from"./cli/vite-reset-cache.js";import l from"./constants/cli-actions.js";import p from"./constants/cli-context.js";import m from"./constants/cli-name.js";const{description:f,version:u}=JSON.parse(o(new URL("./package.json",import.meta.url),"utf8")),v=()=>{process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.on("data",r).setEncoding("utf8").resume())},O=new n;O.name(m).description(f).version(u).hook("preAction",((o,e)=>{global.viteBoostAction=e.name()}));const w=new i("--host","Ability to access the local instance on other devices under the same network.").default(!1),k=new i("--only-client","Build/run only client side part.").default(!1),g=new i("--port [port]","Server port.").default(3e3),b=new i("--mode [mode]","Env mode.").env("VITE_ENV_MODE").default("production");O.command(l.dev).description("Run development server.").addOption(w).addOption(new i("--reset-cache","Clear vite cache before run.").default(!1)).addOption(b).action((async({host:o,resetCache:e,mode:n})=>{e&&await c();const i=async e=>{const{server:i,config:t}=await s({version:u,isHost:o,isPrintInfo:e,mode:n});p.server=i,p.config=t};return p.reboot=i,v(),i()})),O.command(l.build).description("Create production build.").addOption(k).addOption(b).addOption(new i("--client-options [client-options]",'Pass vite build options for client. Example: --client-options="--ssrManifest"').env("VITE_BUILD_CLIENT_OPTIONS").default("")).addOption(new i("--server-options [server-options]","Pass vite build options for server.").env("VITE_BUILD_SERVER_OPTIONS").default("")).addOption(new i("--unlock-robots","Change general directive Disallow to Allow in robots.txt").default(!1)).action((async({onlyClient:o,clientOptions:e,serverOptions:n,mode:i,unlockRobots:r})=>{await t({isOnlyClient:o,isUnlockRobots:r,clientOptions:e,serverOptions:n,mode:i})})),O.command(l.start).description("Run production server.").addOption(w).addOption(g).addOption(k).action((({host:o,port:e,onlyClient:n})=>{const i=async i=>{const{server:t,config:r}=await d({version:u,isHost:o,isPrintInfo:i,port:e,onlyClient:n});p.server=t,p.config=r};return p.reboot=i,v(),i()})),O.command(l.preview).description("Build and preview production.").addOption(k).addOption(w).addOption(g).addOption(b).action((async({host:o,port:n,onlyClient:i,mode:r})=>{global.viteBoostStartTime=performance.now();const s=async t=>{const{server:r,config:s}=await d({version:u,isHost:o,isPrintInfo:t,port:n,onlyClient:i});r.on("listening",(()=>{setTimeout((()=>{s.getLogger().info(e.yellow("\n Running preview mode... \n"))}),0)})),p.server=r,p.config=s};p.reboot=s,v();await t({mode:r,isWatch:!0,isOnlyClient:i,clientOptions:"-w",serverOptions:"-w",onFinish:()=>{s()}})})),O.command(l.buildDocker).description("Create docker image with production build.").requiredOption("--image-name <image-name>","Docker image name.").addOption(new i("--docker-options [docker-options]","Extra docker options which pass to docker build command.")).addOption(new i("--docker-file [docker-file]","Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).")).addOption(k).addOption(b).action((async({imageName:o,dockerOptions:e,dockerFile:n,onlyClient:i,mode:t})=>{await a({imageName:o,dockerOptions:e,dockerFile:n,isOnlyClient:i,mode:t})})),O.parse();
|
|
3
3
|
//# sourceMappingURL=cli.js.map
|
package/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport chalk from 'chalk';\nimport { Command, Option } from 'commander';\nimport runBuild from '@cli/build';\nimport onKeyPress from '@cli/keyboard-input';\nimport runDev from '@cli/run-dev';\nimport runProd from '@cli/run-prod';\nimport viteResetCache from '@cli/vite-reset-cache';\nimport CliActions from '@constants/cli-actions';\nimport cliContext from '@constants/cli-context';\nimport cliName from '@constants/cli-name';\n\n/**\n * Parse package meta\n */\nconst { description, version } = JSON.parse(\n readFileSync(new URL('./package.json', import.meta.url), 'utf8'),\n) as { name: string; description: string; version: string };\n\n/**\n * Enable shortcuts\n * listen keyboard command\n */\nconst enableShortcuts = (): void => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n process.stdin.on('data', onKeyPress).setEncoding('utf8').resume();\n }\n};\n\nconst program = new Command();\n\nprogram\n .name(cliName)\n .description(description)\n .version(version)\n .hook('preAction', (_, actionCommand) => {\n // pass cli action to plugin config\n global.viteBoostAction = actionCommand.name();\n });\n\n/**\n * Common options\n */\nconst hostOption = new Option(\n '--host',\n 'Ability to access the local instance on other devices under the same network.',\n).default(false);\nconst onlyClientOption = new Option('--only-client', 'Build/run only client side part.').default(\n false,\n);\nconst portOption = new Option('--port [port]', 'Server port.').default(3000);\nconst envModeOption = new Option('--mode [mode]', 'Env mode.')\n .env('VITE_ENV_MODE')\n .default('production');\n\n/**\n * Cli commands\n */\n\nprogram\n .command(CliActions.dev)\n .description('Run development server.')\n .addOption(hostOption)\n .addOption(new Option('--reset-cache', 'Clear vite cache before run.').default(false))\n .addOption(envModeOption)\n .action(async ({ host, resetCache, mode }) => {\n if (resetCache) {\n await viteResetCache();\n }\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runDev({ version, isHost: host, isPrintInfo, mode });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.build)\n .description('Create production build.')\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .addOption(\n new Option(\n '--client-options [client-options]',\n 'Pass vite build options for client. Example: --client-options=\"--ssrManifest\"',\n )\n .env('VITE_BUILD_CLIENT_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option('--server-options [server-options]', 'Pass vite build options for server.')\n .env('VITE_BUILD_SERVER_OPTIONS')\n .default(''),\n )\n .action(async ({ onlyClient, clientOptions, serverOptions, mode }) => {\n await runBuild({
|
|
1
|
+
{"version":3,"file":"cli.js","sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync } from 'fs';\nimport chalk from 'chalk';\nimport { Command, Option } from 'commander';\nimport runBuild from '@cli/build';\nimport onKeyPress from '@cli/keyboard-input';\nimport runDev from '@cli/run-dev';\nimport runDockerBuild from '@cli/run-docker-build';\nimport runProd from '@cli/run-prod';\nimport viteResetCache from '@cli/vite-reset-cache';\nimport CliActions from '@constants/cli-actions';\nimport cliContext from '@constants/cli-context';\nimport cliName from '@constants/cli-name';\n\n/**\n * Parse package meta\n */\nconst { description, version } = JSON.parse(\n readFileSync(new URL('./package.json', import.meta.url), 'utf8'),\n) as { name: string; description: string; version: string };\n\n/**\n * Enable shortcuts\n * listen keyboard command\n */\nconst enableShortcuts = (): void => {\n if (process.stdin.isTTY) {\n process.stdin.setRawMode(true);\n process.stdin.on('data', onKeyPress).setEncoding('utf8').resume();\n }\n};\n\nconst program = new Command();\n\nprogram\n .name(cliName)\n .description(description)\n .version(version)\n .hook('preAction', (_, actionCommand) => {\n // pass cli action to plugin config\n global.viteBoostAction = actionCommand.name();\n });\n\n/**\n * Common options\n */\nconst hostOption = new Option(\n '--host',\n 'Ability to access the local instance on other devices under the same network.',\n).default(false);\nconst onlyClientOption = new Option('--only-client', 'Build/run only client side part.').default(\n false,\n);\nconst portOption = new Option('--port [port]', 'Server port.').default(3000);\nconst envModeOption = new Option('--mode [mode]', 'Env mode.')\n .env('VITE_ENV_MODE')\n .default('production');\n\n/**\n * Cli commands\n */\n\nprogram\n .command(CliActions.dev)\n .description('Run development server.')\n .addOption(hostOption)\n .addOption(new Option('--reset-cache', 'Clear vite cache before run.').default(false))\n .addOption(envModeOption)\n .action(async ({ host, resetCache, mode }) => {\n if (resetCache) {\n await viteResetCache();\n }\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runDev({ version, isHost: host, isPrintInfo, mode });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.build)\n .description('Create production build.')\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .addOption(\n new Option(\n '--client-options [client-options]',\n 'Pass vite build options for client. Example: --client-options=\"--ssrManifest\"',\n )\n .env('VITE_BUILD_CLIENT_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option('--server-options [server-options]', 'Pass vite build options for server.')\n .env('VITE_BUILD_SERVER_OPTIONS')\n .default(''),\n )\n .addOption(\n new Option(\n '--unlock-robots',\n 'Change general directive Disallow to Allow in robots.txt',\n ).default(false),\n )\n .action(async ({ onlyClient, clientOptions, serverOptions, mode, unlockRobots }) => {\n await runBuild({\n isOnlyClient: onlyClient,\n isUnlockRobots: unlockRobots,\n clientOptions,\n serverOptions,\n mode,\n });\n });\n\nprogram\n .command(CliActions.start)\n .description('Run production server.')\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(onlyClientOption)\n .action(({ host, port, onlyClient }) => {\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n onlyClient,\n });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n return command();\n });\n\nprogram\n .command(CliActions.preview)\n .description('Build and preview production.')\n .addOption(onlyClientOption)\n .addOption(hostOption)\n .addOption(portOption)\n .addOption(envModeOption)\n .action(async ({ host, port, onlyClient, mode }) => {\n global.viteBoostStartTime = performance.now();\n\n const command = async (isPrintInfo?: boolean): Promise<void> => {\n const { server, config } = await runProd({\n version,\n isHost: host,\n isPrintInfo,\n port,\n onlyClient,\n });\n\n server.on('listening', () => {\n setTimeout(() => {\n config.getLogger().info(chalk.yellow('\\n Running preview mode... \\n'));\n }, 0);\n });\n\n cliContext.server = server;\n cliContext.config = config;\n };\n\n cliContext.reboot = command;\n\n enableShortcuts();\n\n const buildOptions = '-w';\n\n await runBuild({\n mode,\n isWatch: true,\n isOnlyClient: onlyClient,\n clientOptions: buildOptions,\n serverOptions: buildOptions,\n onFinish: () => {\n void command();\n },\n });\n });\n\nprogram\n .command(CliActions.buildDocker)\n .description('Create docker image with production build.')\n .requiredOption('--image-name <image-name>', 'Docker image name.')\n .addOption(\n new Option(\n '--docker-options [docker-options]',\n 'Extra docker options which pass to docker build command.',\n ),\n )\n .addOption(\n new Option(\n '--docker-file [docker-file]',\n 'Name of the Dockerfile (Default is PLUGIN_PATH/workflow/Dockerfile).',\n ),\n )\n .addOption(onlyClientOption)\n .addOption(envModeOption)\n .action(async ({ imageName, dockerOptions, dockerFile, onlyClient, mode }) => {\n await runDockerBuild({\n imageName,\n dockerOptions,\n dockerFile,\n isOnlyClient: onlyClient,\n mode,\n });\n });\n\nprogram.parse();\n"],"names":["description","version","JSON","parse","readFileSync","URL","url","enableShortcuts","process","stdin","isTTY","setRawMode","on","onKeyPress","setEncoding","resume","program","Command","name","cliName","hook","_","actionCommand","global","viteBoostAction","hostOption","Option","default","onlyClientOption","portOption","envModeOption","env","command","CliActions","dev","addOption","action","async","host","resetCache","mode","viteResetCache","isPrintInfo","server","config","runDev","isHost","cliContext","reboot","build","onlyClient","clientOptions","serverOptions","unlockRobots","runBuild","isOnlyClient","isUnlockRobots","start","port","runProd","preview","viteBoostStartTime","performance","now","setTimeout","getLogger","info","chalk","yellow","isWatch","onFinish","buildDocker","requiredOption","imageName","dockerOptions","dockerFile","runDockerBuild"],"mappings":";0bAkBA,MAAMA,YAAEA,EAAWC,QAAEA,GAAYC,KAAKC,MACpCC,EAAa,IAAIC,IAAI,6BAA8BC,KAAM,SAOrDC,EAAkB,KAClBC,QAAQC,MAAMC,QAChBF,QAAQC,MAAME,YAAW,GACzBH,QAAQC,MAAMG,GAAG,OAAQC,GAAYC,YAAY,QAAQC,SAC1D,EAGGC,EAAU,IAAIC,EAEpBD,EACGE,KAAKC,GACLnB,YAAYA,GACZC,QAAQA,GACRmB,KAAK,aAAa,CAACC,EAAGC,KAErBC,OAAOC,gBAAkBF,EAAcJ,MAAM,IAMjD,MAAMO,EAAa,IAAIC,EACrB,SACA,iFACAC,SAAQ,GACJC,EAAmB,IAAIF,EAAO,gBAAiB,oCAAoCC,SACvF,GAEIE,EAAa,IAAIH,EAAO,gBAAiB,gBAAgBC,QAAQ,KACjEG,EAAgB,IAAIJ,EAAO,gBAAiB,aAC/CK,IAAI,iBACJJ,QAAQ,cAMXX,EACGgB,QAAQC,EAAWC,KACnBlC,YAAY,2BACZmC,UAAUV,GACVU,UAAU,IAAIT,EAAO,gBAAiB,gCAAgCC,SAAQ,IAC9EQ,UAAUL,GACVM,QAAOC,OAASC,OAAMC,aAAYC,WAC7BD,SACIE,IAGR,MAAMT,EAAUK,MAAOK,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBC,EAAO,CAAE5C,UAAS6C,OAAQR,EAAMI,cAAaF,SAE9EO,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAAShB,EAEpBzB,IAEOyB,GAAS,IAGpBhB,EACGgB,QAAQC,EAAWgB,OACnBjD,YAAY,4BACZmC,UAAUP,GACVO,UAAUL,GACVK,UACC,IAAIT,EACF,oCACA,iFAECK,IAAI,6BACJJ,QAAQ,KAEZQ,UACC,IAAIT,EAAO,oCAAqC,uCAC7CK,IAAI,6BACJJ,QAAQ,KAEZQ,UACC,IAAIT,EACF,kBACA,4DACAC,SAAQ,IAEXS,QAAOC,OAASa,aAAYC,gBAAeC,gBAAeZ,OAAMa,yBACzDC,EAAS,CACbC,aAAcL,EACdM,eAAgBH,EAChBF,gBACAC,gBACAZ,QACA,IAGNxB,EACGgB,QAAQC,EAAWwB,OACnBzD,YAAY,0BACZmC,UAAUV,GACVU,UAAUN,GACVM,UAAUP,GACVQ,QAAO,EAAGE,OAAMoB,OAAMR,iBACrB,MAAMlB,EAAUK,MAAOK,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBe,EAAQ,CACvC1D,UACA6C,OAAQR,EACRI,cACAgB,OACAR,eAGFH,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAO5B,OAJAG,EAAWC,OAAShB,EAEpBzB,IAEOyB,GAAS,IAGpBhB,EACGgB,QAAQC,EAAW2B,SACnB5D,YAAY,iCACZmC,UAAUP,GACVO,UAAUV,GACVU,UAAUN,GACVM,UAAUL,GACVM,QAAOC,OAASC,OAAMoB,OAAMR,aAAYV,WACvCjB,OAAOsC,mBAAqBC,YAAYC,MAExC,MAAM/B,EAAUK,MAAOK,IACrB,MAAMC,OAAEA,EAAMC,OAAEA,SAAiBe,EAAQ,CACvC1D,UACA6C,OAAQR,EACRI,cACAgB,OACAR,eAGFP,EAAO/B,GAAG,aAAa,KACrBoD,YAAW,KACTpB,EAAOqB,YAAYC,KAAKC,EAAMC,OAAO,kCAAkC,GACtE,EAAE,IAGPrB,EAAWJ,OAASA,EACpBI,EAAWH,OAASA,CAAM,EAG5BG,EAAWC,OAAShB,EAEpBzB,UAIM+C,EAAS,CACbd,OACA6B,SAAS,EACTd,aAAcL,EACdC,cANmB,KAOnBC,cAPmB,KAQnBkB,SAAU,KACHtC,GAAS,GAEhB,IAGNhB,EACGgB,QAAQC,EAAWsC,aACnBvE,YAAY,8CACZwE,eAAe,4BAA6B,sBAC5CrC,UACC,IAAIT,EACF,oCACA,6DAGHS,UACC,IAAIT,EACF,8BACA,yEAGHS,UAAUP,GACVO,UAAUL,GACVM,QAAOC,OAASoC,YAAWC,gBAAeC,aAAYzB,aAAYV,iBAC3DoC,EAAe,CACnBH,YACAC,gBACAC,aACApB,aAAcL,EACdV,QACA,IAGNxB,EAAQb"}
|
package/constants/cli-actions.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e;!function(e){e.dev="dev",e.build="build",e.start="start",e.preview="preview"}(e||(e={}));var r=e;export{r as default};
|
|
1
|
+
var e;!function(e){e.dev="dev",e.build="build",e.buildDocker="build-docker",e.start="start",e.preview="preview"}(e||(e={}));var r=e;export{r as default};
|
|
2
2
|
//# sourceMappingURL=cli-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-actions.js","sources":["../../src/constants/cli-actions.ts"],"sourcesContent":["enum CliActions {\n dev = 'dev',\n build = 'build',\n start = 'start',\n preview = 'preview',\n}\n\nexport default CliActions;\n"],"names":["CliActions","CliActions$1"],"mappings":"AAAA,IAAKA,GAAL,SAAKA,GACHA,EAAA,IAAA,MACAA,EAAA,MAAA,QACAA,EAAA,MAAA,QACAA,EAAA,QAAA,SACD,
|
|
1
|
+
{"version":3,"file":"cli-actions.js","sources":["../../src/constants/cli-actions.ts"],"sourcesContent":["enum CliActions {\n dev = 'dev',\n build = 'build',\n buildDocker = 'build-docker',\n start = 'start',\n preview = 'preview',\n}\n\nexport default CliActions;\n"],"names":["CliActions","CliActions$1"],"mappings":"AAAA,IAAKA,GAAL,SAAKA,GACHA,EAAA,IAAA,MACAA,EAAA,MAAA,QACAA,EAAA,YAAA,eACAA,EAAA,MAAA,QACAA,EAAA,QAAA,SACD,CAND,CAAKA,IAAAA,EAMJ,CAAA,IAED,IAAAC,EAAeD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ResolvedConfig } from 'vite';
|
|
2
|
+
declare const markerFileName = "server/.dev";
|
|
3
|
+
/**
|
|
4
|
+
* Create dev marker
|
|
5
|
+
*
|
|
6
|
+
* @see printServerInfo
|
|
7
|
+
*/
|
|
8
|
+
declare const createDevMarker: (isProd: boolean, { root, build: buildConf }: ResolvedConfig) => void;
|
|
9
|
+
export { createDevMarker, markerFileName };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import r from"node:fs";import e from"node:path";const o="server/.dev",t=(t,{root:i,build:s})=>{const n=e.resolve(i,s.outDir),c=`${n}/${o}`;t?r.existsSync(c)&&r.rmSync(c):(r.existsSync(n)||r.mkdirSync(n,{recursive:!0}),r.writeFileSync(c,""))};export{t as createDevMarker,o as markerFileName};
|
|
2
|
+
//# sourceMappingURL=dev-marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev-marker.js","sources":["../../src/helpers/dev-marker.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport type { ResolvedConfig } from 'vite';\n\nconst markerFileName = 'server/.dev';\n\n/**\n * Create dev marker\n *\n * @see printServerInfo\n */\nconst createDevMarker = (isProd: boolean, { root, build: buildConf }: ResolvedConfig): void => {\n const devMarkerPath = path.resolve(root, buildConf.outDir);\n const devMarker = `${devMarkerPath}/${markerFileName}`;\n\n if (!isProd) {\n if (!fs.existsSync(devMarkerPath)) {\n fs.mkdirSync(devMarkerPath, { recursive: true });\n }\n\n fs.writeFileSync(devMarker, '');\n } else if (fs.existsSync(devMarker)) {\n fs.rmSync(devMarker);\n }\n};\n\nexport { createDevMarker, markerFileName };\n"],"names":["markerFileName","createDevMarker","isProd","root","build","buildConf","devMarkerPath","path","resolve","outDir","devMarker","fs","existsSync","rmSync","mkdirSync","recursive","writeFileSync"],"mappings":"gDAIM,MAAAA,EAAiB,cAOjBC,EAAkB,CAACC,GAAmBC,OAAMC,MAAOC,MACvD,MAAMC,EAAgBC,EAAKC,QAAQL,EAAME,EAAUI,QAC7CC,EAAY,GAAGJ,KAAiBN,IAEjCE,EAMMS,EAAGC,WAAWF,IACvBC,EAAGE,OAAOH,IANLC,EAAGC,WAAWN,IACjBK,EAAGG,UAAUR,EAAe,CAAES,WAAW,IAG3CJ,EAAGK,cAAcN,EAAW,IAG7B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import o from"node:fs";import{performance as e}from"node:perf_hooks";import r from"chalk";import t from"../constants/cli-actions.js";import s from"../constants/cli-name.js";import{markerFileName as i}from"./dev-marker.js";import n from"./print-server-urls.js";import m from"./resolve-server-urls.js";async function a(a,d,{version:l="unknown"}){const{action:p}=d.getPluginConfig()??{},{isProd:f,host:c,root:g}=d.getParams(),v=`${g}/${i}`,h=d.getLogger(),u=global.viteBoostStartTime??e.now(),$=r.dim(`ready in ${r.reset(r.bold(Math.ceil(e.now()-u)))} ms`);h.info(`\n ${r.green(`${r.bold(s.toUpperCase())} v${l}`)} ${$}\n`,{clear:!h.hasWarned});const w=d.getVite()?.config,b=!w?.mode&&!o.existsSync(v),j=await m(a,{host:c,isHttps:"boolean"==typeof w?.server.https&&w?.server.https,rawBase:w?.rawBase}),k=w?.mode||b?d.mode:`production ${r.red("NODE_ENV=development")}`;if(h.info(r.dim(r.green(" ➜"))+r.dim(" Mode: ")+r.blue(k)),f)n(j,(o=>h.info(o)));else{const o=d.getVite();o.resolvedUrls=j,o.printUrls()}p===t.dev&&h.info(r.dim(r.green(" ➜"))+r.dim(" press ")+r.bold("h")+r.dim(" to show help"))}export{a as default};
|
|
2
2
|
//# sourceMappingURL=print-server-info.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-server-info.js","sources":["../../src/helpers/print-server-info.ts"],"sourcesContent":["import fs from 'node:fs';\nimport type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport CliActions from '@constants/cli-actions';\nimport cliName from '@constants/cli-name';\nimport printServerUrls from '@helpers/print-server-urls';\nimport resolveServerUrls from '@helpers/resolve-server-urls';\nimport type ServerConfig from '@services/server-config';\n\ninterface IPrintServerInfoParams {\n version?: string;\n}\n\n/**\n * Print server info\n */\nasync function printServerInfo(\n server: Server,\n config: ServerConfig,\n { version = 'unknown' }: IPrintServerInfoParams,\n): Promise<void> {\n const { action } = config.getPluginConfig() ?? {};\n const { isProd, host, root } = config.getParams();\n const devMarker = `${root}
|
|
1
|
+
{"version":3,"file":"print-server-info.js","sources":["../../src/helpers/print-server-info.ts"],"sourcesContent":["import fs from 'node:fs';\nimport type { Server } from 'node:net';\nimport { performance } from 'node:perf_hooks';\nimport chalk from 'chalk';\nimport CliActions from '@constants/cli-actions';\nimport cliName from '@constants/cli-name';\nimport { markerFileName } from '@helpers/dev-marker';\nimport printServerUrls from '@helpers/print-server-urls';\nimport resolveServerUrls from '@helpers/resolve-server-urls';\nimport type ServerConfig from '@services/server-config';\n\ninterface IPrintServerInfoParams {\n version?: string;\n}\n\n/**\n * Print server info\n */\nasync function printServerInfo(\n server: Server,\n config: ServerConfig,\n { version = 'unknown' }: IPrintServerInfoParams,\n): Promise<void> {\n const { action } = config.getPluginConfig() ?? {};\n const { isProd, host, root } = config.getParams();\n const devMarker = `${root}/${markerFileName}`;\n\n const Logger = config.getLogger();\n const perfStart = global.viteBoostStartTime ?? performance.now();\n const startupDurationString = chalk.dim(\n `ready in ${chalk.reset(chalk.bold(Math.ceil(performance.now() - perfStart)))} ms`,\n );\n\n Logger.info(\n `\\n ${chalk.green(\n `${chalk.bold(cliName.toUpperCase())} v${version}`,\n )} ${startupDurationString}\\n`,\n { clear: !Logger.hasWarned },\n );\n\n const viteConfig = config.getVite()?.config;\n const isProdBuild = !viteConfig?.mode && !fs.existsSync(devMarker);\n const resolvedUrls = await resolveServerUrls(server, {\n host,\n isHttps: typeof viteConfig?.server.https === 'boolean' ? viteConfig?.server.https : false,\n rawBase: viteConfig?.['rawBase'],\n });\n const mode =\n viteConfig?.mode || isProdBuild\n ? config.mode\n : `production ${chalk.red('NODE_ENV=development')}`;\n\n Logger.info(chalk.dim(chalk.green(' ➜')) + chalk.dim(' Mode: ') + chalk.blue(mode));\n\n if (!isProd) {\n const vite = config.getVite()!;\n\n vite.resolvedUrls = resolvedUrls;\n vite.printUrls();\n } else {\n printServerUrls(resolvedUrls, (msg) => Logger.info(msg));\n }\n\n if (action === CliActions.dev) {\n Logger.info(\n chalk.dim(chalk.green(' ➜')) +\n chalk.dim(' press ') +\n chalk.bold('h') +\n chalk.dim(' to show help'),\n );\n }\n}\n\nexport default printServerInfo;\n"],"names":["async","printServerInfo","server","config","version","action","getPluginConfig","isProd","host","root","getParams","devMarker","markerFileName","Logger","getLogger","perfStart","global","viteBoostStartTime","performance","now","startupDurationString","chalk","dim","reset","bold","Math","ceil","info","green","cliName","toUpperCase","clear","hasWarned","viteConfig","getVite","isProdBuild","mode","fs","existsSync","resolvedUrls","resolveServerUrls","isHttps","https","rawBase","red","blue","printServerUrls","msg","vite","printUrls","CliActions","dev"],"mappings":"4SAkBAA,eAAeC,EACbC,EACAC,GACAC,QAAEA,EAAU,YAEZ,MAAMC,OAAEA,GAAWF,EAAOG,mBAAqB,CAAA,GACzCC,OAAEA,EAAMC,KAAEA,EAAIC,KAAEA,GAASN,EAAOO,YAChCC,EAAY,GAAGF,KAAQG,IAEvBC,EAASV,EAAOW,YAChBC,EAAYC,OAAOC,oBAAsBC,EAAYC,MACrDC,EAAwBC,EAAMC,IAClC,YAAYD,EAAME,MAAMF,EAAMG,KAAKC,KAAKC,KAAKR,EAAYC,MAAQJ,WAGnEF,EAAOc,KACL,OAAON,EAAMO,MACX,GAAGP,EAAMG,KAAKK,EAAQC,mBAAmB1B,SACrCgB,MACN,CAAEW,OAAQlB,EAAOmB,YAGnB,MAAMC,EAAa9B,EAAO+B,WAAW/B,OAC/BgC,GAAeF,GAAYG,OAASC,EAAGC,WAAW3B,GAClD4B,QAAqBC,EAAkBtC,EAAQ,CACnDM,OACAiC,QAA6C,kBAA7BR,GAAY/B,OAAOwC,OAAsBT,GAAY/B,OAAOwC,MAC5EC,QAASV,GAAsB,UAE3BG,EACJH,GAAYG,MAAQD,EAChBhC,EAAOiC,KACP,cAAcf,EAAMuB,IAAI,0BAI9B,GAFA/B,EAAOc,KAAKN,EAAMC,IAAID,EAAMO,MAAM,QAAUP,EAAMC,IAAI,eAAiBD,EAAMwB,KAAKT,IAE7E7B,EAMHuC,EAAgBP,GAAeQ,GAAQlC,EAAOc,KAAKoB,SANxC,CACX,MAAMC,EAAO7C,EAAO+B,UAEpBc,EAAKT,aAAeA,EACpBS,EAAKC,WACN,CAIG5C,IAAW6C,EAAWC,KACxBtC,EAAOc,KACLN,EAAMC,IAAID,EAAMO,MAAM,QACpBP,EAAMC,IAAI,YACVD,EAAMG,KAAK,KACXH,EAAMC,IAAI,iBAGlB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o from"chalk";function e(e,
|
|
1
|
+
import o from"chalk";function e(e,n){const r=e=>o.cyan(e.replace(/:(\d+)\//,((e,n)=>`:${o.bold(n)}/`)));for(const c of e.local)n(` ${o.green("➜")} ${o.bold("Local")}: ${r(c)}`);for(const c of e.network)n(` ${o.green("➜")} ${o.bold("Network")}: ${r(c)}`);n("\n")}export{e as default};
|
|
2
2
|
//# sourceMappingURL=print-server-urls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"print-server-urls.js","sources":["../../src/helpers/print-server-urls.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Logger, ResolvedServerUrls } from 'vite';\n\n/**\n * Print server urls\n * @see https://github.com/vitejs/vite/blob/711dd807610b39538e9955970145d52e4ca1d8c0/packages/vite/src/node/logger.ts#LL142C1-L162C2\n * vite not export this function\n */\nfunction printServerUrls(urls: ResolvedServerUrls, info: Logger['info']): void {\n const colorUrl = (url: string) =>\n chalk.cyan(url.replace(/:(\\d+)\\//, (_, port) => `:${chalk.bold(port)}/`));\n for (const url of urls.local) {\n info(` ${chalk.green('➜')} ${chalk.bold('Local')}: ${colorUrl(url)}`);\n }\n for (const url of urls.network) {\n info(` ${chalk.green('➜')} ${chalk.bold('Network')}: ${colorUrl(url)}`);\n }\n}\n\nexport default printServerUrls;\n"],"names":["printServerUrls","urls","info","colorUrl","url","chalk","cyan","replace","_","port","bold","local","green","network"],"mappings":"qBAQA,SAASA,EAAgBC,EAA0BC,GACjD,MAAMC,EAAYC,GAChBC,EAAMC,KAAKF,EAAIG,QAAQ,YAAY,CAACC,EAAGC,IAAS,IAAIJ,EAAMK,KAAKD,SACjE,IAAK,MAAML,KAAOH,EAAKU,MACrBT,EAAK,KAAKG,EAAMO,MAAM,SAASP,EAAMK,KAAK,eAAeP,EAASC,MAEpE,IAAK,MAAMA,KAAOH,EAAKY,QACrBX,EAAK,KAAKG,EAAMO,MAAM,SAASP,EAAMK,KAAK,eAAeP,EAASC,
|
|
1
|
+
{"version":3,"file":"print-server-urls.js","sources":["../../src/helpers/print-server-urls.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Logger, ResolvedServerUrls } from 'vite';\n\n/**\n * Print server urls\n * @see https://github.com/vitejs/vite/blob/711dd807610b39538e9955970145d52e4ca1d8c0/packages/vite/src/node/logger.ts#LL142C1-L162C2\n * vite not export this function\n */\nfunction printServerUrls(urls: ResolvedServerUrls, info: Logger['info']): void {\n const colorUrl = (url: string) =>\n chalk.cyan(url.replace(/:(\\d+)\\//, (_, port) => `:${chalk.bold(port)}/`));\n for (const url of urls.local) {\n info(` ${chalk.green('➜')} ${chalk.bold('Local')}: ${colorUrl(url)}`);\n }\n for (const url of urls.network) {\n info(` ${chalk.green('➜')} ${chalk.bold('Network')}: ${colorUrl(url)}`);\n }\n\n info('\\n');\n}\n\nexport default printServerUrls;\n"],"names":["printServerUrls","urls","info","colorUrl","url","chalk","cyan","replace","_","port","bold","local","green","network"],"mappings":"qBAQA,SAASA,EAAgBC,EAA0BC,GACjD,MAAMC,EAAYC,GAChBC,EAAMC,KAAKF,EAAIG,QAAQ,YAAY,CAACC,EAAGC,IAAS,IAAIJ,EAAMK,KAAKD,SACjE,IAAK,MAAML,KAAOH,EAAKU,MACrBT,EAAK,KAAKG,EAAMO,MAAM,SAASP,EAAMK,KAAK,eAAeP,EAASC,MAEpE,IAAK,MAAMA,KAAOH,EAAKY,QACrBX,EAAK,KAAKG,EAAMO,MAAM,SAASP,EAAMK,KAAK,eAAeP,EAASC,MAGpEF,EAAK,KACP"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import o from"node:fs";import t from"node:path";import e from"chalk";const n=(n,l)=>{const i=`${t.resolve(n,l)}/client/robots.txt`;if(!o.existsSync(i))return void console.warn(`Failed to unlock robots.txt, file not exist: ${i}`);const r=o.readFileSync(i,{encoding:"utf-8"}).replace(/Disallow: \/$/m,"Allow: /");o.writeFileSync(i,r,{encoding:"utf-8"}),console.info(e.blue("\nrobots.txt unlocked."))};export{n as default};
|
|
2
|
+
//# sourceMappingURL=unlock-robots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unlock-robots.js","sources":["../../src/helpers/unlock-robots.ts"],"sourcesContent":["import fs from 'node:fs';\nimport path from 'node:path';\nimport chalk from 'chalk';\n\n/**\n * Change general directive Disallow to Allow in robots.txt.\n */\nconst unlockRobots = (root: string, buildFolder: string): void => {\n const buildPath = path.resolve(root, buildFolder);\n const robotsFile = `${buildPath}/client/robots.txt`;\n\n if (!fs.existsSync(robotsFile)) {\n console.warn(`Failed to unlock robots.txt, file not exist: ${robotsFile}`);\n\n return;\n }\n\n const data = fs\n .readFileSync(robotsFile, { encoding: 'utf-8' })\n .replace(/Disallow: \\/$/m, 'Allow: /');\n\n fs.writeFileSync(robotsFile, data, { encoding: 'utf-8' });\n\n console.info(chalk.blue('\\nrobots.txt unlocked.'));\n};\n\nexport default unlockRobots;\n"],"names":["unlockRobots","root","buildFolder","robotsFile","path","resolve","fs","existsSync","console","warn","data","readFileSync","encoding","replace","writeFileSync","info","chalk","blue"],"mappings":"qEAOA,MAAMA,EAAe,CAACC,EAAcC,KAClC,MACMC,EAAa,GADDC,EAAKC,QAAQJ,EAAMC,uBAGrC,IAAKI,EAAGC,WAAWJ,GAGjB,YAFAK,QAAQC,KAAK,gDAAgDN,KAK/D,MAAMO,EAAOJ,EACVK,aAAaR,EAAY,CAAES,SAAU,UACrCC,QAAQ,iBAAkB,YAE7BP,EAAGQ,cAAcX,EAAYO,EAAM,CAAEE,SAAU,UAE/CJ,QAAQO,KAAKC,EAAMC,KAAK,0BAA0B"}
|
package/package.json
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{extname as t}from"node:path";import o from"../constants/plugin-name.js";const
|
|
1
|
+
import{extname as t}from"node:path";import o from"../constants/plugin-name.js";const s=t=>`import n from '${o}/helpers/import-route';${t}`.replace(/(lazyNR)(:\s*)(\(\)\s*=>\s*import\([^)]+\))/gs,"lazy$2()=>n($3)");function r(){return{name:`${o}-normalize-route`,transform:(o,r)=>{const e=t(r).split("?")[0];if(!r.includes("node_modules")&&[".js",".ts",".tsx"].includes(e)&&(t=>/\[.*{.*path:.*lazyNR:.+import/s.test(t))(o))return{code:s(o),map:{mappings:""}}}}}export{r as default};
|
|
2
2
|
//# sourceMappingURL=normalize-route.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-route.js","sources":["../../src/plugins/normalize-route.ts"],"sourcesContent":["import { extname } from 'node:path';\nimport type { Plugin } from 'vite';\nimport PLUGIN_NAME from '@constants/plugin-name';\n\n/**\n * Detect route file\n */\nconst isRoutesFile = (code: string): boolean => /\\[.*{.*path:.*lazyNR:.+import/s.test(code);\n\n/**\n * Add normalize wrapper to lazy imports\n */\nconst normalizeRoutes = (code: string): string =>\n `import n from '${PLUGIN_NAME}/helpers/import-route';${code}`.replace(\n /(lazyNR)(:\\s*)(\\(\\)\\s*=>\\s*import\\([^)]+\\))/gs,\n 'lazy$2()=>n($3)',\n );\n\n/**\n * Add possibility to export route components like FCRoute or FCCRoute\n * USAGE: { path: '/', lazyNR: () => import('./pages/home') }\n * @see FCRoute\n * @see FCCRoute\n * @constructor\n */\nfunction ViteNormalizeRouterPlugin(): Plugin {\n return {\n name: `${PLUGIN_NAME}-normalize-route`,\n transform: (code, id) => {\n const extName = extname(id)
|
|
1
|
+
{"version":3,"file":"normalize-route.js","sources":["../../src/plugins/normalize-route.ts"],"sourcesContent":["import { extname } from 'node:path';\nimport type { Plugin } from 'vite';\nimport PLUGIN_NAME from '@constants/plugin-name';\n\n/**\n * Detect route file\n */\nconst isRoutesFile = (code: string): boolean => /\\[.*{.*path:.*lazyNR:.+import/s.test(code);\n\n/**\n * Add normalize wrapper to lazy imports\n */\nconst normalizeRoutes = (code: string): string =>\n `import n from '${PLUGIN_NAME}/helpers/import-route';${code}`.replace(\n /(lazyNR)(:\\s*)(\\(\\)\\s*=>\\s*import\\([^)]+\\))/gs,\n 'lazy$2()=>n($3)',\n );\n\n/**\n * Add possibility to export route components like FCRoute or FCCRoute\n * USAGE: { path: '/', lazyNR: () => import('./pages/home') }\n * @see FCRoute\n * @see FCCRoute\n * @constructor\n */\nfunction ViteNormalizeRouterPlugin(): Plugin {\n return {\n name: `${PLUGIN_NAME}-normalize-route`,\n transform: (code, id) => {\n const extName = extname(id).split('?')[0]!;\n\n if (\n id.includes('node_modules') ||\n !['.js', '.ts', '.tsx'].includes(extName) ||\n !isRoutesFile(code)\n ) {\n return;\n }\n\n return {\n code: normalizeRoutes(code),\n map: { mappings: '' },\n };\n },\n };\n}\n\nexport default ViteNormalizeRouterPlugin;\n"],"names":["normalizeRoutes","code","PLUGIN_NAME","replace","ViteNormalizeRouterPlugin","name","transform","id","extName","extname","split","includes","test","isRoutesFile","map","mappings"],"mappings":"+EAOA,MAKMA,EAAmBC,GACvB,kBAAkBC,2BAAqCD,IAAOE,QAC5D,gDACA,mBAUJ,SAASC,IACP,MAAO,CACLC,KAAM,GAAGH,oBACTI,UAAW,CAACL,EAAMM,KAChB,MAAMC,EAAUC,EAAQF,GAAIG,MAAM,KAAK,GAEvC,IACEH,EAAGI,SAAS,iBACX,CAAC,MAAO,MAAO,QAAQA,SAASH,IA1BpB,CAACP,GAA0B,iCAAiCW,KAAKX,GA2B7EY,CAAaZ,GAKhB,MAAO,CACLA,KAAMD,EAAgBC,GACtBa,IAAK,CAAEC,SAAU,IAClB,EAGP"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
FROM node:18.13.0-alpine
|
|
2
|
+
|
|
3
|
+
MAINTAINER Yarmaliuk Mikhail <mikhail.yarmaliuk@lomray.com>
|
|
4
|
+
|
|
5
|
+
ARG ROOT_PATH
|
|
6
|
+
ARG BUILD_PATH
|
|
7
|
+
ARG RUN_TYPE=ssr
|
|
8
|
+
ARG ENV_MODE=production
|
|
9
|
+
ARG WEB_PATH=/var/www
|
|
10
|
+
|
|
11
|
+
ENV NODE_ENV=${ENV_MODE}
|
|
12
|
+
ENV TYPE=${RUN_TYPE}
|
|
13
|
+
|
|
14
|
+
RUN mkdir -p $WEB_PATH
|
|
15
|
+
|
|
16
|
+
WORKDIR $WEB_PATH
|
|
17
|
+
|
|
18
|
+
COPY ${BUILD_PATH} $WEB_PATH/build
|
|
19
|
+
COPY ./package.json $WEB_PATH/package.json
|
|
20
|
+
COPY ./package-lock.json $WEB_PATH/package-lock.json
|
|
21
|
+
|
|
22
|
+
RUN npm ci --omit=dev
|
|
23
|
+
|
|
24
|
+
CMD npm run start:${TYPE} -- --host
|