diff --git a/.github/workflows/publish-cli.yml b/.github/workflows/publish-cli.yml
index 42e754f..4ca2c1c 100644
--- a/.github/workflows/publish-cli.yml
+++ b/.github/workflows/publish-cli.yml
@@ -1,5 +1,5 @@
name: Publish create-vite-express package
-on:
+on:
push:
tags:
- cli-v*
@@ -22,8 +22,8 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
- registry-url: 'https://registry.npmjs.org'
+ registry-url: "https://registry.npmjs.org"
node-version: 20
- run: cd create-vite-express && yarn install && yarn build && npm publish
env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 9cf1350..72411b4 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -1,5 +1,5 @@
name: Publish vite-express package
-on:
+on:
push:
tags:
- v*
@@ -22,10 +22,10 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
- registry-url: 'https://registry.npmjs.org'
+ registry-url: "https://registry.npmjs.org"
node-version: 20
- run: yarn install
- run: yarn build
- run: npm publish
env:
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 6116898..9abadcc 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -21,4 +21,3 @@ jobs:
node-version: 20
- run: yarn install
- run: yarn test:local
-
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
index bd3207d..f892501 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -3,5 +3,6 @@
"useTabs": false,
"tabWidth": 2,
"semi": true,
- "singleQuote": false
+ "singleQuote": false,
+ "trailingComma": "all"
}
diff --git a/create-vite-express/src/cli.ts b/create-vite-express/src/cli.ts
index eb9e88a..337ef47 100644
--- a/create-vite-express/src/cli.ts
+++ b/create-vite-express/src/cli.ts
@@ -41,7 +41,7 @@ async function main() {
const templatePath = path.join(__dirname, "..", "templates", templateName);
if (!fs.existsSync(templatePath)) {
console.error(
- kolorist.red(`Template ${templateName} at ${templatePath} not found!`)
+ kolorist.red(`Template ${templateName} at ${templatePath} not found!`),
);
process.exit(1);
}
@@ -55,7 +55,7 @@ async function main() {
fs.copySync(templatePath, projectPath);
fs.moveSync(
path.join(projectPath, "_gitignore"),
- path.join(projectPath, ".gitignore")
+ path.join(projectPath, ".gitignore"),
);
console.log(`${kolorist.green("✔")} Done! You can start with:`);
diff --git a/create-vite-express/templates/react-ts/index.html b/create-vite-express/templates/react-ts/index.html
index 7acaff1..110f81d 100644
--- a/create-vite-express/templates/react-ts/index.html
+++ b/create-vite-express/templates/react-ts/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/create-vite-express/templates/react-ts/src/client/main.tsx b/create-vite-express/templates/react-ts/src/client/main.tsx
index 924f091..f95159a 100644
--- a/create-vite-express/templates/react-ts/src/client/main.tsx
+++ b/create-vite-express/templates/react-ts/src/client/main.tsx
@@ -8,5 +8,5 @@ import App from "./App";
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
-
+ ,
);
diff --git a/create-vite-express/templates/react-ts/src/server/main.ts b/create-vite-express/templates/react-ts/src/server/main.ts
index 1a0c19f..3e7b4d8 100644
--- a/create-vite-express/templates/react-ts/src/server/main.ts
+++ b/create-vite-express/templates/react-ts/src/server/main.ts
@@ -8,5 +8,5 @@ app.get("/hello", (_, res) => {
});
ViteExpress.listen(app, 3000, () =>
- console.log("Server is listening on port 3000...")
+ console.log("Server is listening on port 3000..."),
);
diff --git a/create-vite-express/templates/react/index.html b/create-vite-express/templates/react/index.html
index 082c284..3401ad5 100644
--- a/create-vite-express/templates/react/index.html
+++ b/create-vite-express/templates/react/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/create-vite-express/templates/react/src/client/main.jsx b/create-vite-express/templates/react/src/client/main.jsx
index f18b0f0..6c99444 100644
--- a/create-vite-express/templates/react/src/client/main.jsx
+++ b/create-vite-express/templates/react/src/client/main.jsx
@@ -1,10 +1,12 @@
+import "./index.css";
+
import React from "react";
import ReactDOM from "react-dom/client";
+
import App from "./App";
-import "./index.css";
ReactDOM.createRoot(document.getElementById("root")).render(
-
+ ,
);
diff --git a/create-vite-express/templates/react/src/server/main.js b/create-vite-express/templates/react/src/server/main.js
index a158845..f0d4ebb 100644
--- a/create-vite-express/templates/react/src/server/main.js
+++ b/create-vite-express/templates/react/src/server/main.js
@@ -8,5 +8,5 @@ app.get("/hello", (req, res) => {
});
ViteExpress.listen(app, 3000, () =>
- console.log("Server is listening on port 3000...")
+ console.log("Server is listening on port 3000..."),
);
diff --git a/create-vite-express/templates/vanilla-ts/index.html b/create-vite-express/templates/vanilla-ts/index.html
index f5ad53e..5569a0e 100644
--- a/create-vite-express/templates/vanilla-ts/index.html
+++ b/create-vite-express/templates/vanilla-ts/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/create-vite-express/templates/vanilla-ts/src/server/main.ts b/create-vite-express/templates/vanilla-ts/src/server/main.ts
index 6ca2443..cfabd50 100644
--- a/create-vite-express/templates/vanilla-ts/src/server/main.ts
+++ b/create-vite-express/templates/vanilla-ts/src/server/main.ts
@@ -8,5 +8,5 @@ app.get("/hello", (_, res) => {
});
ViteExpress.listen(app, 3000, () =>
- console.log("Server is listening on port 3000...")
+ console.log("Server is listening on port 3000..."),
);
diff --git a/create-vite-express/templates/vanilla/index.html b/create-vite-express/templates/vanilla/index.html
index 5895207..79b5ec6 100644
--- a/create-vite-express/templates/vanilla/index.html
+++ b/create-vite-express/templates/vanilla/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/create-vite-express/templates/vanilla/src/server/main.js b/create-vite-express/templates/vanilla/src/server/main.js
index 9323e3f..3278590 100644
--- a/create-vite-express/templates/vanilla/src/server/main.js
+++ b/create-vite-express/templates/vanilla/src/server/main.js
@@ -8,5 +8,5 @@ app.get("/hello", (req, res) => {
});
ViteExpress.listen(app, 3000, () =>
- console.log("Server is listening on port 3000...")
+ console.log("Server is listening on port 3000..."),
);
diff --git a/create-vite-express/templates/vue-ts/index.html b/create-vite-express/templates/vue-ts/index.html
index 2a63a5c..e13f3da 100644
--- a/create-vite-express/templates/vue-ts/index.html
+++ b/create-vite-express/templates/vue-ts/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/create-vite-express/templates/vue-ts/src/server/main.ts b/create-vite-express/templates/vue-ts/src/server/main.ts
index b243c43..672d80f 100644
--- a/create-vite-express/templates/vue-ts/src/server/main.ts
+++ b/create-vite-express/templates/vue-ts/src/server/main.ts
@@ -8,5 +8,5 @@ app.get("/hello", (_, res) => {
});
ViteExpress.listen(app, 3000, () =>
- console.log("Server is listening on port 3000...")
+ console.log("Server is listening on port 3000..."),
);
diff --git a/create-vite-express/templates/vue/index.html b/create-vite-express/templates/vue/index.html
index 3dc6787..db8bbea 100644
--- a/create-vite-express/templates/vue/index.html
+++ b/create-vite-express/templates/vue/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/create-vite-express/templates/vue/src/server/main.js b/create-vite-express/templates/vue/src/server/main.js
index c2db228..1d9915c 100644
--- a/create-vite-express/templates/vue/src/server/main.js
+++ b/create-vite-express/templates/vue/src/server/main.js
@@ -8,5 +8,5 @@ app.get("/hello", (req, res) => {
});
ViteExpress.listen(app, 3000, () =>
- console.log("Server is listening on port 3000...")
+ console.log("Server is listening on port 3000..."),
);
diff --git a/src/main.ts b/src/main.ts
index 5e9d07b..5edb3a5 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -41,8 +41,8 @@ function info(msg: string) {
const timestamp = new Date().toLocaleString("en-US").split(",")[1].trim();
console.log(
`${pc.dim(timestamp)} ${pc.bold(pc.cyan("[vite-express]"))} ${pc.green(
- msg
- )}`
+ msg,
+ )}`,
);
}
@@ -72,8 +72,8 @@ async function resolveConfig(): Promise {
if (Config.inlineViteConfig) {
info(
`${pc.yellow("Inline config")} detected, ignoring ${pc.yellow(
- "Vite config file"
- )}`
+ "Vite config file",
+ )}`,
);
return {
@@ -87,7 +87,7 @@ async function resolveConfig(): Promise {
try {
const config = await resolveConfig({}, "build");
info(
- `Using ${pc.yellow("Vite")} to resolve the ${pc.yellow("config file")}`
+ `Using ${pc.yellow("Vite")} to resolve the ${pc.yellow("config file")}`,
);
return config;
} catch (e) {
@@ -95,9 +95,9 @@ async function resolveConfig(): Promise {
info(
pc.red(
`Unable to use ${pc.yellow("Vite")}, running in ${pc.yellow(
- "viteless"
- )} mode`
- )
+ "viteless",
+ )} mode`,
+ ),
);
}
} catch (e) {
@@ -122,9 +122,9 @@ async function resolveConfig(): Promise {
info(
pc.red(
`Unable to locate ${pc.yellow(
- "vite.config.*s file"
- )}, using default options`
- )
+ "vite.config.*s file",
+ )}, using default options`,
+ ),
);
return getDefaultViteConfig();
@@ -151,8 +151,8 @@ async function serveStatic(): Promise {
info(`${pc.red(`Static files at ${pc.gray(distPath)} not found!`)}`);
info(
`${pc.yellow(
- `Did you forget to run ${pc.bold(pc.green("vite build"))} command?`
- )}`
+ `Did you forget to run ${pc.bold(pc.green("vite build"))} command?`,
+ )}`,
);
} else {
info(`${pc.green(`Serving static files from ${pc.gray(distPath)}`)}`);
@@ -165,13 +165,13 @@ const stubMiddleware: RequestHandler = (req, res, next) => next();
async function injectStaticMiddleware(
app: core.Express,
- middleware: RequestHandler
+ middleware: RequestHandler,
) {
const config = await getViteConfig();
app.use(config.base, middleware);
const stubMiddlewareLayer = app._router.stack.find(
- (layer: { handle?: RequestHandler }) => layer.handle === stubMiddleware
+ (layer: { handle?: RequestHandler }) => layer.handle === stubMiddleware,
);
if (stubMiddlewareLayer !== undefined) {
@@ -192,7 +192,7 @@ function isIgnoredPath(path: string, req: express.Request) {
function findClosestIndexToRoot(
reqPath: string,
- root: string
+ root: string,
): string | undefined {
const basePath = reqPath.slice(0, reqPath.lastIndexOf("/"));
const dirs = basePath.split("/");
@@ -209,7 +209,7 @@ function findClosestIndexToRoot(
async function injectViteIndexMiddleware(
app: core.Express,
- server: ViteDevServer
+ server: ViteDevServer,
) {
const config = await getViteConfig();
@@ -256,7 +256,7 @@ async function startServer(server: http.Server | https.Server) {
clearScreen: false,
appType: "custom",
server: { middlewareMode: true },
- })
+ }),
);
server.on("close", () => vite.close());
@@ -274,7 +274,7 @@ function config(config: ConfigurationOptions) {
async function bind(
app: core.Express,
server: http.Server | https.Server,
- callback?: () => void
+ callback?: () => void,
) {
info(`Running in ${pc.yellow(Config.mode)} mode`);
diff --git a/tests/env/dist/index.html b/tests/env/dist/index.html
index db4ac48..d0004fa 100644
--- a/tests/env/dist/index.html
+++ b/tests/env/dist/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/tests/env/dist/subpath/index.html b/tests/env/dist/subpath/index.html
index 988bcba..90a7ef0 100644
--- a/tests/env/dist/subpath/index.html
+++ b/tests/env/dist/subpath/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/tests/env/index.html b/tests/env/index.html
index db4ac48..d0004fa 100644
--- a/tests/env/index.html
+++ b/tests/env/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/tests/env/subpath/index.html b/tests/env/subpath/index.html
index 988bcba..90a7ef0 100644
--- a/tests/env/subpath/index.html
+++ b/tests/env/subpath/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/tests/noIndexEnv/dist/subpath/index.html b/tests/noIndexEnv/dist/subpath/index.html
index 988bcba..90a7ef0 100644
--- a/tests/noIndexEnv/dist/subpath/index.html
+++ b/tests/noIndexEnv/dist/subpath/index.html
@@ -1,4 +1,4 @@
-
+
diff --git a/tests/noIndexEnv/subpath/index.html b/tests/noIndexEnv/subpath/index.html
index 988bcba..90a7ef0 100644
--- a/tests/noIndexEnv/subpath/index.html
+++ b/tests/noIndexEnv/subpath/index.html
@@ -1,4 +1,4 @@
-
+