@michijs/dev-server 0.8.1-beta.4 → 0.8.1-beta.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/bin/actions/start.js +8 -2
- package/bin/config/config.d.ts +1 -0
- package/bin/config/config.js +1 -0
- package/bin/types.d.ts +5 -0
- package/package.json +1 -1
package/bin/actions/start.js
CHANGED
|
@@ -26,13 +26,19 @@ export const start = async (callback) => {
|
|
|
26
26
|
const proxyReq = http.request(esbuildProxyRequestOptions, (proxyRes) => {
|
|
27
27
|
// If esbuild returns "not found", send a custom 404 page
|
|
28
28
|
if (!proxyRes.statusCode || proxyRes.statusCode === 404) {
|
|
29
|
-
res.writeHead(200, {
|
|
29
|
+
res.writeHead(200, {
|
|
30
|
+
"Content-Type": "text/html",
|
|
31
|
+
...config.aditionalHeaders,
|
|
32
|
+
});
|
|
30
33
|
// TODO: Find a better way to do this
|
|
31
34
|
res.end(fs.readFileSync(getPath(`${config.esbuildOptions.outdir}/${config.public.indexName}`)));
|
|
32
35
|
return;
|
|
33
36
|
}
|
|
34
37
|
// Otherwise, forward the response from esbuild to the client
|
|
35
|
-
res.writeHead(proxyRes.statusCode,
|
|
38
|
+
res.writeHead(proxyRes.statusCode, {
|
|
39
|
+
...proxyRes.headers,
|
|
40
|
+
...config.aditionalHeaders,
|
|
41
|
+
});
|
|
36
42
|
proxyRes.pipe(res, { end: true });
|
|
37
43
|
});
|
|
38
44
|
// Forward the body of the request to esbuild
|
package/bin/config/config.d.ts
CHANGED
package/bin/config/config.js
CHANGED
package/bin/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { BuildOptions } from "esbuild";
|
|
|
2
2
|
import type { ImageResource, WebAppManifest } from "web-app-manifest";
|
|
3
3
|
import type { assetsSizes } from "./constants.js";
|
|
4
4
|
import type { Page } from "playwright-core";
|
|
5
|
+
import type { OutgoingHttpHeader, OutgoingHttpHeaders } from "http";
|
|
5
6
|
export interface Viewport {
|
|
6
7
|
width: number;
|
|
7
8
|
height: number;
|
|
@@ -176,6 +177,10 @@ export interface Config {
|
|
|
176
177
|
showLinkedPackages?: boolean;
|
|
177
178
|
/** Documentation: https://esbuild.github.io/plugins/#build-options */
|
|
178
179
|
esbuildOptions?: BuildOptions;
|
|
180
|
+
/**
|
|
181
|
+
* Headers to send from the development server
|
|
182
|
+
*/
|
|
183
|
+
aditionalHeaders?: OutgoingHttpHeaders | OutgoingHttpHeader[];
|
|
179
184
|
}
|
|
180
185
|
export type DefaultEnvironment = "PRODUCTION" | "DISTRIBUTION" | "DEVELOPMENT";
|
|
181
186
|
export interface ServerConfig extends Config {
|