@marko/run 0.0.1-beta9 → 0.1.0
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 +108 -107
- package/dist/cli/index.mjs +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* 🚀 Fastest way to build a Marko app
|
|
14
14
|
* 💖 Scales from zero configuration
|
|
15
15
|
* ⚡️ Pages live-reload as you make changes
|
|
16
|
-
* 📁 Directory-based routes, layouts and middleware
|
|
16
|
+
* 📁 Directory-based routes, layouts, and middleware
|
|
17
17
|
* 🖌️ TypeScript powered editor support
|
|
18
18
|
* 🧬 [Designed with web standards](https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern) to run anywhere
|
|
19
19
|
|
|
@@ -25,7 +25,6 @@ And when you build your production-ready app:
|
|
|
25
25
|
* 🚢 Deploy to multiple platforms
|
|
26
26
|
|
|
27
27
|
## Installation
|
|
28
|
-
|
|
29
28
|
> **Warning**
|
|
30
29
|
> This project is in BETA - use at your own peril, but please do provide helpful feedback.
|
|
31
30
|
|
|
@@ -52,23 +51,23 @@ Finally open `http://localhost:3000` 🚀
|
|
|
52
51
|
|
|
53
52
|
### CLI
|
|
54
53
|
|
|
55
|
-
**`dev`** - Start development server in watch mode
|
|
56
|
-
```
|
|
54
|
+
**`dev`** - Start a development server in watch mode
|
|
55
|
+
```sh
|
|
57
56
|
> npm exec marko-run
|
|
58
57
|
```
|
|
59
58
|
or (with explicit sub command)
|
|
60
|
-
```
|
|
59
|
+
```sh
|
|
61
60
|
> npm exec marko-run dev
|
|
62
61
|
```
|
|
63
62
|
|
|
64
63
|
|
|
65
64
|
**`build`** - Create a production build
|
|
66
|
-
```
|
|
65
|
+
```sh
|
|
67
66
|
> npm exec marko-run build
|
|
68
67
|
```
|
|
69
68
|
|
|
70
|
-
**`preview`** - Create a production build and start preview server
|
|
71
|
-
```
|
|
69
|
+
**`preview`** - Create a production build and start the preview server
|
|
70
|
+
```sh
|
|
72
71
|
> npm exec marko-run preview
|
|
73
72
|
```
|
|
74
73
|
|
|
@@ -98,19 +97,17 @@ export default defineConfig({
|
|
|
98
97
|
|
|
99
98
|
### Routeable Files
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
The following filenames will be discovered in any directory inside your application’s [routes directory](#routes-directory).
|
|
100
|
+
The router only recognizes certain filenames which are all prefixed with `+` ([Why?](#What-about-markoserve)). The following filenames will be discovered in any directory inside your application’s [routes directory](#routes-directory).
|
|
104
101
|
|
|
105
102
|
#### `+page.marko`
|
|
106
103
|
|
|
107
|
-
These files establish a route at the current directory path which will be served for `GET` requests with the HTML content of the page. Only one page may
|
|
104
|
+
These files establish a route at the current directory path which will be served for `GET` requests with the HTML content of the page. Only one page may exist for any served path.
|
|
108
105
|
|
|
109
106
|
#### `+layout.marko`
|
|
110
107
|
|
|
111
108
|
These files provide a **layout component**, which will wrap all nested layouts and pages.
|
|
112
109
|
|
|
113
|
-
Layouts are like any other Marko component with no extra constraints. Each layout receives the request, path params, URL, and route metadata as input, as well as a `renderBody` which
|
|
110
|
+
Layouts are like any other Marko component, with no extra constraints. Each layout receives the request, path params, URL, and route metadata as input, as well as a `renderBody` which refers to the nested page that is being rendered.
|
|
114
111
|
|
|
115
112
|
```marko
|
|
116
113
|
<main>
|
|
@@ -137,36 +134,36 @@ Typically, these will be `.js` or `.ts` files depending on your project. Like pa
|
|
|
137
134
|
- Handler functions are synchronous or asynchronous functions that
|
|
138
135
|
- Receives a `context` and `next` argument,
|
|
139
136
|
- The `context` argument contains the WHATWG request object, path parameters, URL, and route metadata.
|
|
140
|
-
- The `next` argument will call the page for
|
|
141
|
-
- Return a WHATWG response, throw a WHATWG response, return undefined. If the function
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
137
|
+
- The `next` argument will call the page for `GET` requests where applicable or return a `204` response.
|
|
138
|
+
- Return a WHATWG response, throw a WHATWG response, and return undefined. If the function returns undefined the `next` argument with be automatically called and used as the response.
|
|
139
|
+
|
|
140
|
+
```js
|
|
141
|
+
export function POST(context, next) {
|
|
142
|
+
const { request, params, url, meta } = context;
|
|
143
|
+
return new Response('Successfully updated', { status: 200 });
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function PUT(context, next) {
|
|
147
|
+
// `next` will be called for you by the runtime
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export async function GET(context, next) {
|
|
151
|
+
// do something before calling `next`
|
|
152
|
+
const response = await next();
|
|
153
|
+
// do something with the response from `next`
|
|
154
|
+
return response;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function DELETE(context, next) {
|
|
158
|
+
return new Response('Successfully removed', { status: 204 });
|
|
159
|
+
}
|
|
160
|
+
```
|
|
164
161
|
</details>
|
|
165
162
|
|
|
166
163
|
|
|
167
164
|
#### `+middleware.*`
|
|
168
165
|
|
|
169
|
-
These files are like layouts, but for handlers. Middleware
|
|
166
|
+
These files are like layouts, but for handlers. Middleware files are called before handlers and let you perform arbitrary work before and after.
|
|
170
167
|
|
|
171
168
|
> **Note**: Unlike handlers, middleware run for all HTTP methods.
|
|
172
169
|
|
|
@@ -180,33 +177,33 @@ These files are like layouts, but for handlers. Middleware get called before han
|
|
|
180
177
|
- Handler functions are synchronous or asynchronous functions that
|
|
181
178
|
- Receives a `context` and `next` argument,
|
|
182
179
|
- The `context` argument contains the WHATWG request object, path parameters, URL, and route metadata.
|
|
183
|
-
- The `next` argument will call the page for
|
|
184
|
-
- Return a WHATWG response, throw a WHATWG response, return undefined. If the function
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
180
|
+
- The `next` argument will call the page for `GET` requests where applicable or return a `204` response.
|
|
181
|
+
- Return a WHATWG response, throw a WHATWG response, and return undefined. If the function returns undefined the `next` argument with be automatically called and used as the response.
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
export default async function(context, next) {
|
|
185
|
+
const requestName = `${context.request.method} ${context.url.href}`;
|
|
186
|
+
let success = true;
|
|
187
|
+
console.log(`${requestName} request started`)
|
|
188
|
+
try {
|
|
189
|
+
return await next(); // Wait for subsequent middleware, handler, and page
|
|
190
|
+
} catch (err) {
|
|
191
|
+
success = false;
|
|
192
|
+
throw err;
|
|
193
|
+
} finally {
|
|
194
|
+
console.log(`${requestName} completed ${success ? 'successfully' : 'with errors'}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
```
|
|
201
198
|
</details>
|
|
202
199
|
|
|
203
200
|
#### `+meta.*`
|
|
204
201
|
|
|
205
|
-
These files represent static metadata to attach to the route. This metadata will be automatically provided on the
|
|
202
|
+
These files represent static metadata to attach to the route. This metadata will be automatically provided on the route `context` when invoking a route.
|
|
206
203
|
|
|
207
204
|
### Special Files
|
|
208
205
|
|
|
209
|
-
In addition to the files above which can be defined in any directory under the
|
|
206
|
+
In addition to the files above which can be defined in any directory under the [routes directory](#routes-directory), some special files can only be defined at its top level. <!-- TODO: do we want to keep this restriction? Having nested 404s would be handy for disambiguating things like “there’s no user with that name” or “that promotion wasn’t found, it may have expired” -->
|
|
210
207
|
|
|
211
208
|
These special pages are subject to a root layout file (`pages/+layout.marko` in the default configuration).
|
|
212
209
|
|
|
@@ -244,7 +241,7 @@ routes/
|
|
|
244
241
|
+page.marko
|
|
245
242
|
</pre>
|
|
246
243
|
|
|
247
|
-
When the path
|
|
244
|
+
When the path `/about` is requested, the routable files execute in the following order:
|
|
248
245
|
|
|
249
246
|
1. Middlewares from root-most to leaf-most
|
|
250
247
|
2. Handler
|
|
@@ -272,44 +269,44 @@ sequenceDiagram
|
|
|
272
269
|
|
|
273
270
|
### Path Structure
|
|
274
271
|
|
|
275
|
-
Within the
|
|
272
|
+
Within the [routes directory](#routes-directory), the directory structure determines the path from which the route is served. There are four types of directory names: **static**, **pathless**, **dynamic**, and **catch-all**.
|
|
276
273
|
|
|
277
|
-
1. **Static directories** - The most common type. Each static directory contributes its name as a segment in the route's served path, like a traditional fileserver. Unless a directory name matches the requirements for one of the below types, it
|
|
274
|
+
1. **Static directories** - The most common type, and the default behavior. Each static directory contributes its name as a segment in the route's served path, like a traditional fileserver. Unless a directory name matches the requirements for one of the below types, it is seen as a static directory.
|
|
278
275
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
276
|
+
Examples:
|
|
277
|
+
```
|
|
278
|
+
/foo
|
|
279
|
+
/users
|
|
280
|
+
/projects
|
|
281
|
+
```
|
|
285
282
|
|
|
286
|
-
2. **Pathless directories** - These directories do **not** contribute their name to the route's served path. Directory names that start with an underscore (`_`) will be
|
|
283
|
+
2. **Pathless directories** - These directories do **not** contribute their name to the route's served path. Directory names that start with an underscore (`_`) will be ignored when parsing the route.
|
|
287
284
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
285
|
+
Examples:
|
|
286
|
+
```
|
|
287
|
+
/_users
|
|
288
|
+
/_public
|
|
289
|
+
```
|
|
293
290
|
|
|
294
291
|
3. **Dynamic directories** - These directories introduce a dynamic parameter to the route's served path and will match any value at that segment. Any directory name that starts with a single dollar sign (`$`) will be a dynamic directory, and the remaining directory name will be the parameter at runtime. If the directory name is exactly `$`, the parameter will not be captured but it will be matched.
|
|
295
292
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
Examples:
|
|
294
|
+
```
|
|
295
|
+
/$id
|
|
296
|
+
/$name
|
|
297
|
+
/$
|
|
298
|
+
```
|
|
302
299
|
|
|
303
300
|
4. **Catch-all directories** - These directories are similar to dynamic directories and introduce a dynamic parameter, but instead of matching a single path segment, they match to the end of the path. Any directory that starts with two dollar signs (`$$`) will be a catch-all directory, and the remaining directory name will be the parameter at runtime. In the case of a directory named `$$`, the parameter name will not be captured but it will match. Catch-all directories can be used to make `404` Not Found routes at any level, including the root.
|
|
304
301
|
|
|
305
|
-
|
|
302
|
+
Because catch-all directories match any path segment and consume the rest of the path, you cannot nest route files in them and no further directories will be traversed.
|
|
306
303
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
304
|
+
Examples:
|
|
305
|
+
```
|
|
306
|
+
/$$all
|
|
307
|
+
/$$rest
|
|
308
|
+
/$$
|
|
309
|
+
```
|
|
313
310
|
|
|
314
311
|
<!-- ### Match Ranking
|
|
315
312
|
|
|
@@ -334,7 +331,7 @@ export default defineConfig({
|
|
|
334
331
|
|
|
335
332
|
### Adapters
|
|
336
333
|
|
|
337
|
-
Adapters provide the means to change the development, build and preview process to fit different deployment platforms and runtimes while allowing authors to write idiomatic code.
|
|
334
|
+
Adapters provide the means to change the development, build, and preview process to fit different deployment platforms and runtimes while allowing authors to write idiomatic code.
|
|
338
335
|
|
|
339
336
|
Specify your adapter in the Vite config when registering the `@marko/run` plugin
|
|
340
337
|
|
|
@@ -356,7 +353,6 @@ export default defineConfig({
|
|
|
356
353
|
- [@marko/run-adapter-node](https://github.com/marko-js/run/blob/main/packages/adapters/node/README.md)
|
|
357
354
|
- [@marko/run-adapter-netlify](https://github.com/marko-js/run/blob/main/packages/adapters/netlify/README.md)
|
|
358
355
|
- [@marko/run-adapter-static](https://github.com/marko-js/run/blob/main/packages/adapters/static/README.md)
|
|
359
|
-
|
|
360
356
|
## Runtime
|
|
361
357
|
|
|
362
358
|
Generally, when using an adapter, this runtime will be abstracted away.
|
|
@@ -380,7 +376,12 @@ async function fetch<T>(request: Request, platform: T) => Promise<Response | voi
|
|
|
380
376
|
|
|
381
377
|
|
|
382
378
|
|
|
383
|
-
This asynchronous function takes a [WHATWG `Request` object](https://fetch.spec.whatwg.org/#request-class)
|
|
379
|
+
This asynchronous function takes a [WHATWG `Request` object](https://fetch.spec.whatwg.org/#request-class) and an object containing any platform-specific data you may want access to, and returns any of
|
|
380
|
+
|
|
381
|
+
- a [WHATWG `Response` object](https://fetch.spec.whatwg.org/#response-class) (generated from executing any matched route files)
|
|
382
|
+
- `undefined` (if the request was not explicitly handled)
|
|
383
|
+
- a `404` status code response (if no route matches the requested path)
|
|
384
|
+
- a `500` status code response (if an error occurs)
|
|
384
385
|
|
|
385
386
|
Express example:
|
|
386
387
|
```ts
|
|
@@ -397,7 +398,7 @@ express()
|
|
|
397
398
|
});
|
|
398
399
|
|
|
399
400
|
if (response) {
|
|
400
|
-
// ...code to apply response to `res`
|
|
401
|
+
// ...code to apply a response to `res`
|
|
401
402
|
} else {
|
|
402
403
|
next();
|
|
403
404
|
}
|
|
@@ -408,12 +409,12 @@ express()
|
|
|
408
409
|
|
|
409
410
|
### Other APIs
|
|
410
411
|
|
|
411
|
-
In some cases you might want more control over when route matching and
|
|
412
|
+
In some cases, you might want more control over when route matching and invocation (creating a response) occur. For instance, you may have middleware in your server which needs to know if there is a matched route. The runtime provides these additional methods:
|
|
412
413
|
|
|
413
414
|
### `Run.match`
|
|
414
415
|
|
|
415
416
|
```ts
|
|
416
|
-
interface
|
|
417
|
+
interface Route {
|
|
417
418
|
params: Record<string, string>;
|
|
418
419
|
meta: unknown;
|
|
419
420
|
}
|
|
@@ -421,7 +422,7 @@ interface interface Route {
|
|
|
421
422
|
function match(method: string, pathname: string) => Route | null;
|
|
422
423
|
```
|
|
423
424
|
|
|
424
|
-
This synchronous function takes an HTTP method and path name
|
|
425
|
+
This synchronous function takes an HTTP method and path name and returns an object representing the best match, or `null` if no match is found.
|
|
425
426
|
|
|
426
427
|
- `params` - a `{ key: value }` collection of any path parameters for the route
|
|
427
428
|
- `meta` - metadata for the route
|
|
@@ -462,7 +463,7 @@ express()
|
|
|
462
463
|
});
|
|
463
464
|
|
|
464
465
|
if (response) {
|
|
465
|
-
// ...code to apply response to `res`
|
|
466
|
+
// ...code to apply a response to `res`
|
|
466
467
|
} else {
|
|
467
468
|
next();
|
|
468
469
|
}
|
|
@@ -476,30 +477,30 @@ express()
|
|
|
476
477
|
|
|
477
478
|
|
|
478
479
|
### Global Namespace
|
|
479
|
-
marko/run provides a global namespace `MarkoRun` with the
|
|
480
|
+
`marko/run` provides a global namespace `MarkoRun` with the following types:
|
|
480
481
|
|
|
481
482
|
**`MarkoRun.Handler`** - Type that represents a handler function to be exported by a +handler or +middleware file
|
|
482
483
|
|
|
483
|
-
**`MarkoRun.CurrentRoute`** - Type of the route's params and
|
|
484
|
+
**`MarkoRun.CurrentRoute`** - Type of the route's params and metadata
|
|
484
485
|
|
|
485
486
|
**`MarkoRun.CurrentContext`** - Type of the request context object in a handler and `out.global` in your Marko files
|
|
486
487
|
|
|
487
488
|
|
|
488
489
|
### Generated Types
|
|
489
|
-
If a [TSConfig](https://www.typescriptlang.org/tsconfig) file is discovered in the project root, the Vite plugin will automatically generate a .d.ts file which provides more specific types for each of your middleware, handlers, layouts and pages. This file will be generated at `.marko-run/routes.d.ts` whenever the project is built - including dev.
|
|
490
|
-
> **Note** TypeScript will not include this file by default.
|
|
490
|
+
If a [TSConfig](https://www.typescriptlang.org/tsconfig) file is discovered in the project root, the Vite plugin will automatically generate a .d.ts file which provides more specific types for each of your middleware, handlers, layouts, and pages. This file will be generated at `.marko-run/routes.d.ts` whenever the project is built - including dev.
|
|
491
|
+
> **Note** TypeScript will not include this file by default. You should use the [Marko VSCode plugin](https://marketplace.visualstudio.com/items?itemName=Marko-JS.marko-vscode) and [add it in your tsconfig](https://www.typescriptlang.org/tsconfig#include).
|
|
491
492
|
|
|
492
|
-
These types are replaced with more specific versions per
|
|
493
|
+
These types are replaced with more specific versions per routable file:
|
|
493
494
|
|
|
494
495
|
**`MarkoRun.Handler`**
|
|
495
496
|
- Overrides context with specific MarkoRun.CurrentContext
|
|
496
497
|
|
|
497
498
|
**`MarkoRun.CurrentRoute`**
|
|
498
499
|
- Adds specific parameters and meta types
|
|
499
|
-
- In middleware and layouts which are used in many routes, this type will be a union of all possible routes that file will see
|
|
500
|
+
- In middleware and layouts which are used in many routes, this type will be a union of all possible routes that the file will see
|
|
500
501
|
|
|
501
502
|
**`MarkoRun.CurrentContext`**
|
|
502
|
-
- In middleware and layouts which are used in many routes, this type will be a union of all possible routes that file will see.
|
|
503
|
+
- In middleware and layouts which are used in many routes, this type will be a union of all possible routes that the file will see.
|
|
503
504
|
- When an adapter is used, it can provide types for the platform
|
|
504
505
|
|
|
505
506
|
## Beta Roadmap
|
|
@@ -512,10 +513,10 @@ These types are replaced with more specific versions per routeable file:
|
|
|
512
513
|
|
|
513
514
|
Once stable @marko/run will replace @marko/serve and improves upon that project in several critical ways.
|
|
514
515
|
|
|
515
|
-
1. Special "route files" (
|
|
516
|
-
2. @marko/serve was built around Webpack. Since Webpack doesn't have great support for SSR
|
|
517
|
-
3. @marko/serve was primarily designed with a node target in mind. @marko/run instead supports an "
|
|
518
|
-
4. The
|
|
519
|
-
5. Built
|
|
516
|
+
1. Special "route files" (e.g. `+page.marko`) improve the developer ergonomics quite substantially. While they may cause a double take initially, making these explicit allows colocating additional components, tests, stories, config, utilities, and whatever else you need alongside the page components. With `@marko/serve` it was far too easy to "accidentally" serve some of your test fixtures :see-no-evil:.
|
|
517
|
+
2. @marko/serve was built around Webpack. Since Webpack doesn't have great support for SSR, a lot of this work was up to us. This was not only a maintenance burden but also lead to some rough edges such as no HMR support (just full page reloading in dev). By switching to Vite with its first-class SSR support, things all come together much more smoothly. <!-- TODO: And we're in good company (LINK TO OTHER META FRAMEWORKS ON VITE)! -->
|
|
518
|
+
3. @marko/serve was primarily designed with a node target in mind. @marko/run instead supports an "adapter" model, where you can author in web standard APIs and build your application to run in Node, Deno, Netlify, Cloudflare, and even a static site.
|
|
519
|
+
4. The programmatic API of `@marko/serve` left some to be desired which made it difficult to integrate into existing development servers and projects. Because of this, public-facing applications at eBay (the largest consumer of Marko) were not able to bring in `@marko/serve`. With `@marko/run` we've worked from the ground up to ensure a flexible enough programmatic API to allow embedding in existing complex applications. Because of this, we're confident that `@marko/run` will see much more use than `@marko/serve` and more investment from us!
|
|
520
|
+
5. Built-in layout management. Strictly speaking, Marko does not need the concept of `+layout.marko` "route file". If you've used Marko before you know it's very easy to treat layouts as normal components. But by bringing these layouts into the router we're able to reduce the amount of JavaScript naively sent to the browser, reduce the amount of boilerplate, and prime ourselves for some plans we have for after Marko 6 is out :eyes:.
|
|
520
521
|
|
|
521
|
-
There's more of course, but we're committed to
|
|
522
|
+
There's more of course, but we're committed to making `@marko/run` the _best way_ to build a Marko application.
|
package/dist/cli/index.mjs
CHANGED
|
@@ -99,6 +99,7 @@ var defaultConfigFileBases = ["serve.config", "vite.config"];
|
|
|
99
99
|
var defaultConfigFileExts = [".js", ".cjs", ".mjs", ".ts", ".mts"];
|
|
100
100
|
var prog = sade("marko-run").version("0.0.1").option("-c, --config", `Provide path to a Vite config file (by default looks for a file starting with ${defaultConfigFileBases.join(" or ")} with one of these extensions: ${defaultConfigFileExts.join(", ")})`).option("-e, --env", "Provide path to a dotenv file");
|
|
101
101
|
prog.command("preview [entry]").describe("Start a production-like server for already-built app files").option("-o, --output", "Directory to serve files from, and write asset files to if `--build` (default: )").option("-p, --port", "Port the server should listen on (defaults: `$PORT` env variable or 3000)").option("-f, --file", "Output file to start").action(async (entry, opts) => {
|
|
102
|
+
process.env.NODE_ENV = "production";
|
|
102
103
|
const config2 = await getViteConfig(cwd, opts.config);
|
|
103
104
|
await build(entry, config2, opts.output, false, opts.env);
|
|
104
105
|
await preview(opts.entry, config2, opts.port, opts.output, opts.env);
|
|
@@ -109,6 +110,7 @@ prog.command("dev [entry]", "", { default: true }).describe("Start development s
|
|
|
109
110
|
await dev(cmd, config2, opts.port, opts.env);
|
|
110
111
|
});
|
|
111
112
|
prog.command("build [entry]").describe("Build the application (without serving it)").option("-o, --output", "Directory to write built files (default: 'build.outDir' in Vite config)").option("--skip-client", "Skip the client-side build").example("build --config vite.config.js").action(async (entry, opts) => {
|
|
113
|
+
process.env.NODE_ENV = "production";
|
|
112
114
|
const config2 = await getViteConfig(cwd, opts.config);
|
|
113
115
|
await build(entry, config2, opts.ouput, opts["skip-client"], opts.env);
|
|
114
116
|
});
|