forked from izu/student-web-if-development-kit
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 68cd20864e | |||
| b3a34dd608 | |||
| 99de2a3167 | |||
| b65a581ed4 | |||
| 986477ab58 | |||
| 4375c846fa | |||
| 49cd290d5a | |||
| 4d828814da | |||
| 112447c6bc | |||
| 027bd25359 |
@@ -20,16 +20,6 @@ Buka URL dari Vite (default: `http://localhost:5173`) lalu akses launcher di `/`
|
||||
| `npm run build` | Build static output ke folder `dist` |
|
||||
| `npm run preview` | Preview hasil build |
|
||||
|
||||
## Deploy Netlify
|
||||
|
||||
Project ini sudah punya konfigurasi Netlify di `netlify.toml`.
|
||||
|
||||
Saat membuat site di Netlify:
|
||||
- Repository: `GuavaPopper/PPL_Staging`
|
||||
- Branch deploy: `Staging`
|
||||
- Build command: `npm run build`
|
||||
- Publish directory: `dist`
|
||||
|
||||
## Struktur Folder
|
||||
|
||||
```
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
|
||||
<head>
|
||||
@@ -1662,7 +1662,7 @@
|
||||
: '<span class="font-normal text-white">ID</span> <span class="text-white/40 mx-2">|</span> <span class="font-bold text-white">EN</span>';
|
||||
}
|
||||
|
||||
const mobileButton = document.getElementById('mobile-lang-toggle-btn');
|
||||
const mobileButton = document.getElementById('lang-toggle-mobile');
|
||||
if (mobileButton) {
|
||||
mobileButton.textContent = currentLang === 'id' ? 'Bahasa: ID' : 'Language: EN';
|
||||
}
|
||||
@@ -2135,4 +2135,4 @@
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
|
||||
Generated
+11
-11
@@ -1,13 +1,13 @@
|
||||
{
|
||||
"name": "roda",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "roda",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC"
|
||||
"name": "roda",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "roda",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -1,14 +1,14 @@
|
||||
{
|
||||
"name": "roda",
|
||||
"version": "1.0.0",
|
||||
"description": "Project website untuk menampilkan sorotan dan prestasi karya mahasiswa program studi Informatika Universitas Tanjungpura.",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node server.js",
|
||||
"dev": "node server.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
"name": "roda",
|
||||
"version": "1.0.0",
|
||||
"description": "Project website untuk menampilkan sorotan dan prestasi karya mahasiswa program studi Informatika Universitas Tanjungpura.",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"start": "node server.js",
|
||||
"dev": "node server.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
[build]
|
||||
command = "npm run build"
|
||||
publish = "dist"
|
||||
|
||||
[build.environment]
|
||||
NODE_VERSION = "22"
|
||||
+1
-2
@@ -6,8 +6,7 @@
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"preview": "vite preview",
|
||||
"test:netlify-build": "node scripts/verify-netlify-build.mjs"
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "^7.1.0"
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
import { existsSync, readdirSync, statSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
const root = process.cwd();
|
||||
const dist = path.join(root, 'dist');
|
||||
const excludedDirs = new Set(['.git', 'dist', 'node_modules']);
|
||||
|
||||
function collectFiles(dir, predicate = () => true) {
|
||||
const entries = readdirSync(dir, { withFileTypes: true });
|
||||
const files = [];
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (!excludedDirs.has(entry.name)) {
|
||||
files.push(...collectFiles(fullPath, predicate));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.isFile() && predicate(fullPath)) {
|
||||
files.push(fullPath);
|
||||
}
|
||||
}
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
if (!existsSync(dist) || !statSync(dist).isDirectory()) {
|
||||
throw new Error('Missing dist directory. Run `npm run build` first.');
|
||||
}
|
||||
|
||||
const missingHtmlFiles = collectFiles(root, (file) => file.endsWith('.html'))
|
||||
.map((file) => path.relative(root, file))
|
||||
.filter((relativePath) => !existsSync(path.join(dist, relativePath)));
|
||||
|
||||
const missingAssetFiles = collectFiles(path.join(root, 'assets'))
|
||||
.map((file) => path.relative(root, file))
|
||||
.filter((relativePath) => !existsSync(path.join(dist, relativePath)));
|
||||
|
||||
const missingFiles = [...missingHtmlFiles, ...missingAssetFiles];
|
||||
|
||||
if (missingFiles.length > 0) {
|
||||
throw new Error(`Missing built files:\n${missingFiles.join('\n')}`);
|
||||
}
|
||||
|
||||
console.log('All source HTML and static asset files are present in dist.');
|
||||
@@ -1,57 +0,0 @@
|
||||
import { cpSync, existsSync, readdirSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { defineConfig } from 'vite';
|
||||
|
||||
const root = path.dirname(fileURLToPath(import.meta.url));
|
||||
const excludedDirs = new Set(['.git', 'dist', 'node_modules']);
|
||||
|
||||
function collectHtmlInputs(dir) {
|
||||
const inputs = {};
|
||||
const entries = readdirSync(dir, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const fullPath = path.join(dir, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
if (!excludedDirs.has(entry.name)) {
|
||||
Object.assign(inputs, collectHtmlInputs(fullPath));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.isFile() && entry.name.endsWith('.html')) {
|
||||
const relativePath = path.relative(root, fullPath);
|
||||
const inputName = relativePath
|
||||
.replace(/\.html$/, '')
|
||||
.replace(/[^a-zA-Z0-9_-]+/g, '_');
|
||||
|
||||
inputs[inputName] = fullPath;
|
||||
}
|
||||
}
|
||||
|
||||
return inputs;
|
||||
}
|
||||
|
||||
function copyStaticAssets() {
|
||||
return {
|
||||
name: 'copy-static-assets',
|
||||
closeBundle() {
|
||||
const source = path.join(root, 'assets');
|
||||
const destination = path.join(root, 'dist', 'assets');
|
||||
|
||||
if (existsSync(source)) {
|
||||
cpSync(source, destination, { recursive: true });
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [copyStaticAssets()],
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: collectHtmlInputs(root),
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user