39 lines
956 B
TypeScript
39 lines
956 B
TypeScript
import { resolve } from "node:path";
|
|
import { environment, verifyRequiredVariables } from "@config";
|
|
import { logger } from "@creations.works/logger";
|
|
import { type PluginOption, createServer } from "vite";
|
|
import solidPlugin from "vite-plugin-solid";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
|
verifyRequiredVariables();
|
|
|
|
function injectEnvPlugin(): PluginOption {
|
|
return {
|
|
name: "inject-env",
|
|
transformIndexHtml(html) {
|
|
return html
|
|
.replace("__FQDN__", environment.fqdn)
|
|
.replace("__BACKEND_URL__", environment.backendUrl);
|
|
},
|
|
};
|
|
}
|
|
|
|
const server = await createServer({
|
|
root: resolve("src"),
|
|
publicDir: resolve("src/public"),
|
|
plugins: [solidPlugin(), tsconfigPaths(), injectEnvPlugin()],
|
|
server: {
|
|
port: environment.port,
|
|
host: environment.host,
|
|
strictPort: true,
|
|
},
|
|
build: {
|
|
target: "esnext",
|
|
},
|
|
});
|
|
|
|
await server.listen();
|
|
|
|
logger.info(
|
|
`Server is running at http://${environment.host}:${environment.port}`,
|
|
);
|