Removed Vite and most packages
Got basic static script working
This commit is contained in:
parent
f360f37d2a
commit
4b5c3f772b
@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
@ -7,7 +7,6 @@
|
||||
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
<div id="root"><p>Hello, world!</p></div>
|
||||
</body>
|
||||
</html>
|
||||
|
2105
package-lock.json
generated
2105
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -6,34 +6,22 @@
|
||||
"url": "https://github.com/notclickable-jordan/starbase-80/"
|
||||
},
|
||||
"version": "1.3.0",
|
||||
"type": "module",
|
||||
"type": "commonjs",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "tsc && vite build",
|
||||
"serve": "vite preview",
|
||||
"start": "node start.js",
|
||||
"build": "tsc src/static.ts && node src/static.js",
|
||||
"html": "html-minifier --remove-comments --collapse-whitespace --input-dir ./dist --output-dir ./dist --file-ext html",
|
||||
"replace": "npm run replace:script",
|
||||
"replace:script": "replace-in-file --configFile replace-script.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/react": "^18.2.45",
|
||||
"@types/react-dom": "^18.2.17",
|
||||
"@types/react-helmet": "^6.1.11",
|
||||
"@vitejs/plugin-react": "^4.2.1",
|
||||
"@types/node": "^20.10.4",
|
||||
"autoprefixer": "^10.4.16",
|
||||
"html-minifier": "^4.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"postcss": "^8.4.32",
|
||||
"prettier": "^3.1.1",
|
||||
"puppeteer": "^21.6.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-helmet": "^6.1.0",
|
||||
"replace-in-file": "^7.0.2",
|
||||
"tailwindcss": "^3.3.6",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.8"
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"prettier": {
|
||||
"arrowParens": "avoid",
|
||||
|
114
src/static.js
Normal file
114
src/static.js
Normal file
@ -0,0 +1,114 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||
function step(op) {
|
||||
if (f) throw new TypeError("Generator is already executing.");
|
||||
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||
switch (op[0]) {
|
||||
case 0: case 1: t = op; break;
|
||||
case 4: _.label++; return { value: op[1], done: false };
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||
default:
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||
if (t[2]) _.ops.pop();
|
||||
_.trys.pop(); continue;
|
||||
}
|
||||
op = body.call(thisArg, _);
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||
}
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var fs = require("fs/promises");
|
||||
var path = require("path");
|
||||
var indexFilePath = path.join(__dirname, "../", "index.html");
|
||||
function writeIndexPage(contents) {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var exception_1;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, fs.writeFile(indexFilePath, contents)];
|
||||
case 1:
|
||||
_a.sent();
|
||||
return [2 /*return*/, resolve(true)];
|
||||
case 2:
|
||||
exception_1 = _a.sent();
|
||||
console.error("Could not write index.html file");
|
||||
reject(exception_1);
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
});
|
||||
});
|
||||
}
|
||||
function readIndexPage() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var _this = this;
|
||||
return __generator(this, function (_a) {
|
||||
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
||||
var index, exception_2;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
_a.trys.push([0, 2, , 3]);
|
||||
return [4 /*yield*/, fs.readFile(indexFilePath)];
|
||||
case 1:
|
||||
index = _a.sent();
|
||||
return [2 /*return*/, resolve(index.toString())];
|
||||
case 2:
|
||||
exception_2 = _a.sent();
|
||||
console.error("Could not read index.html file");
|
||||
reject(exception_2);
|
||||
return [3 /*break*/, 3];
|
||||
case 3: return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
}); })];
|
||||
});
|
||||
});
|
||||
}
|
||||
function start() {
|
||||
return __awaiter(this, void 0, void 0, function () {
|
||||
var index, newText, rootDiv, rootDivReplacement, newIndex;
|
||||
return __generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0: return [4 /*yield*/, readIndexPage()];
|
||||
case 1:
|
||||
index = _a.sent();
|
||||
newText = "<p>Hello, world!</p>";
|
||||
rootDiv = '<div id="root"></div>';
|
||||
rootDivReplacement = '<div id="root">$1</div>';
|
||||
newIndex = index.replace(rootDiv, rootDivReplacement.replace("$1", newText));
|
||||
return [4 /*yield*/, writeIndexPage(newIndex)];
|
||||
case 2:
|
||||
_a.sent();
|
||||
return [2 /*return*/];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
start();
|
43
src/static.ts
Normal file
43
src/static.ts
Normal file
@ -0,0 +1,43 @@
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
|
||||
const indexFilePath = path.join(__dirname, "../", "index.html");
|
||||
|
||||
async function writeIndexPage(contents: string): Promise<boolean> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
await fs.writeFile(indexFilePath, contents);
|
||||
return resolve(true);
|
||||
} catch (exception) {
|
||||
console.error("Could not write index.html file");
|
||||
reject(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function readIndexPage(): Promise<string> {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const index = await fs.readFile(indexFilePath);
|
||||
|
||||
return resolve(index.toString());
|
||||
} catch (exception) {
|
||||
console.error("Could not read index.html file");
|
||||
reject(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function start(): Promise<void> {
|
||||
const index = await readIndexPage();
|
||||
|
||||
const newText = "<p>Hello, world!</p>";
|
||||
const rootDiv = '<div id="root"></div>';
|
||||
const rootDivReplacement = '<div id="root">$1</div>';
|
||||
|
||||
const newIndex = index.replace(rootDiv, rootDivReplacement.replace("$1", newText));
|
||||
|
||||
await writeIndexPage(newIndex);
|
||||
}
|
||||
|
||||
start();
|
1
src/vite-env.d.ts
vendored
1
src/vite-env.d.ts
vendored
@ -1 +0,0 @@
|
||||
/// <reference types="vite/client" />
|
@ -1,21 +1,11 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["DOM", "DOM.Iterable", "ESNext"],
|
||||
"allowJs": false,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": false,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
"esModuleInterop": true,
|
||||
"module": "CommonJS"
|
||||
},
|
||||
"include": ["src", "public"],
|
||||
"references": [{ "path": "./tsconfig.node.json" }]
|
||||
"include": ["src/*.ts"]
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
"allowSyntheticDefaultImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
server: {
|
||||
watch: {
|
||||
usePolling: true,
|
||||
},
|
||||
host: true,
|
||||
strictPort: true,
|
||||
port: 4173,
|
||||
},
|
||||
});
|
Loading…
Reference in New Issue
Block a user