Updated
This commit is contained in:
parent
baed4fd80e
commit
fec3abd5d8
15 changed files with 141 additions and 119 deletions
|
|
@ -2,5 +2,6 @@ node_modules/
|
||||||
.git
|
.git
|
||||||
.gitignore
|
.gitignore
|
||||||
*.log
|
*.log
|
||||||
dist
|
.output
|
||||||
|
.vinxi
|
||||||
Dockerfile
|
Dockerfile
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 846 B |
Binary file not shown.
|
Before Width: | Height: | Size: 626 B |
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,23 +0,0 @@
|
||||||
import { consola } from 'consola';
|
|
||||||
import * as fs from 'fs';
|
|
||||||
import * as path from 'path';
|
|
||||||
import sharp from 'sharp';
|
|
||||||
|
|
||||||
try {
|
|
||||||
const dirPath = path.resolve('./public')
|
|
||||||
|
|
||||||
if (fs.existsSync(dirPath)) {
|
|
||||||
const inputSrc = './src/images/favicon.png'
|
|
||||||
const favicon = dirPath + '/favicon.png'
|
|
||||||
const faviconBuffer = await sharp(inputSrc).png({ quality: 90 }).resize(48).toBuffer()
|
|
||||||
await sharp(faviconBuffer).toFile(favicon)
|
|
||||||
consola.success('Favicon generated successfully')
|
|
||||||
} else {
|
|
||||||
consola.error('Directory does not exist:', dirPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (error.message.includes('missing')) {
|
|
||||||
consola.error('Source favicon does not exist')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
26
frontend/@dasig/scripts/node/generateFavicon.ts
Normal file
26
frontend/@dasig/scripts/node/generateFavicon.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
// deno-lint-ignore-file no-explicit-any
|
||||||
|
import { consola } from "consola";
|
||||||
|
import * as fs from "node:fs";
|
||||||
|
import * as path from "node:path";
|
||||||
|
import sharp from "sharp";
|
||||||
|
|
||||||
|
try {
|
||||||
|
const dirPath = path.resolve("./public");
|
||||||
|
|
||||||
|
if (fs.existsSync(dirPath)) {
|
||||||
|
const inputSrc = "./src/images/favicon.png";
|
||||||
|
const favicon = dirPath + "/favicon.png";
|
||||||
|
const faviconBuffer = await sharp(inputSrc)
|
||||||
|
.png({ quality: 90 })
|
||||||
|
.resize(48)
|
||||||
|
.toBuffer();
|
||||||
|
await sharp(faviconBuffer).toFile(favicon);
|
||||||
|
consola.success("Favicon generated successfully");
|
||||||
|
} else {
|
||||||
|
consola.error("Directory does not exist:", dirPath);
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error.message.includes("missing")) {
|
||||||
|
consola.error("Source favicon does not exist");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
import { consola } from 'consola';
|
|
||||||
import sharp from 'sharp';
|
|
||||||
import yargs from 'yargs';
|
|
||||||
import { hideBin } from 'yargs/helpers';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const argv = yargs(hideBin(process.argv))
|
|
||||||
.option('name', {
|
|
||||||
alias: 'n',
|
|
||||||
describe: 'Specify the name of the image',
|
|
||||||
type: 'string',
|
|
||||||
demandOption: true,
|
|
||||||
})
|
|
||||||
.option('size', {
|
|
||||||
alias: 's',
|
|
||||||
describe: 'Specify the size of the image',
|
|
||||||
type: 'number',
|
|
||||||
demandOption: true,
|
|
||||||
})
|
|
||||||
.argv;
|
|
||||||
|
|
||||||
const name = argv.name;
|
|
||||||
const size = argv.size;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const avifOutputPath = `./src/@dasig/images/${name.toString().split('.').slice(0, -1).join('.')}.avif`
|
|
||||||
const webpOutputPath = `./src/@dasig/images/${name.toString().split('.').slice(0, -1).join('.')}.webp`
|
|
||||||
|
|
||||||
const avifBuffer = await sharp(`./src/images/${name}`).avif({ quality: 60 }).resize(size).toBuffer()
|
|
||||||
await sharp(avifBuffer).toFile(avifOutputPath)
|
|
||||||
consola.success(`${name} successfully optimized in Avif`)
|
|
||||||
|
|
||||||
const webpBuffer = await sharp(`./src/images/${name}`).webp({ quality: 75 }).resize(size).toBuffer()
|
|
||||||
await sharp(webpBuffer).toFile(webpOutputPath)
|
|
||||||
consola.success(`${name} successfully optimized in Webp`)
|
|
||||||
} catch (error) {
|
|
||||||
consola.error('Error optimizing image:', error)
|
|
||||||
if (error.message.includes('missing')) consola.error(`${name} could not be found on image folder`)
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
|
|
||||||
49
frontend/@dasig/scripts/node/optimizeImage.ts
Normal file
49
frontend/@dasig/scripts/node/optimizeImage.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
// deno-lint-ignore-file no-explicit-any
|
||||||
|
|
||||||
|
import { consola } from "consola";
|
||||||
|
import process from "node:process";
|
||||||
|
import sharp from "sharp";
|
||||||
|
import yargs from "yargs";
|
||||||
|
import { hideBin } from "yargs/helpers";
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const argv = yargs(hideBin(process.argv))
|
||||||
|
.option("name", {
|
||||||
|
alias: "n",
|
||||||
|
describe: "Specify the name of the image",
|
||||||
|
type: "string",
|
||||||
|
demandOption: true,
|
||||||
|
})
|
||||||
|
.option("size", {
|
||||||
|
alias: "s",
|
||||||
|
describe: "Specify the size of the image",
|
||||||
|
type: "number",
|
||||||
|
demandOption: true,
|
||||||
|
}).argv;
|
||||||
|
|
||||||
|
const name = argv.name;
|
||||||
|
const size = argv.size;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const avifOutputPath = `./@dasig/images/${name.toString().split(".").slice(0, -1).join(".")}.avif`;
|
||||||
|
const webpOutputPath = `./@dasig/images/${name.toString().split(".").slice(0, -1).join(".")}.webp`;
|
||||||
|
|
||||||
|
const avifBuffer = await sharp(`./src/images/${name}`)
|
||||||
|
.avif({ quality: 60 })
|
||||||
|
.resize(size)
|
||||||
|
.toBuffer();
|
||||||
|
await sharp(avifBuffer).toFile(avifOutputPath);
|
||||||
|
consola.success(`${name} successfully optimized in Avif`);
|
||||||
|
|
||||||
|
const webpBuffer = await sharp(`./src/images/${name}`)
|
||||||
|
.webp({ quality: 75 })
|
||||||
|
.resize(size)
|
||||||
|
.toBuffer();
|
||||||
|
await sharp(webpBuffer).toFile(webpOutputPath);
|
||||||
|
consola.success(`${name} successfully optimized in Webp`);
|
||||||
|
} catch (error: any) {
|
||||||
|
consola.error("Error optimizing image:", error);
|
||||||
|
if (error.message.includes("missing"))
|
||||||
|
consola.error(`${name} could not be found on image folder`);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
import { consola } from 'consola';
|
|
||||||
import sharp from 'sharp';
|
|
||||||
import yargs from 'yargs';
|
|
||||||
import { hideBin } from 'yargs/helpers';
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
const argv = yargs(hideBin(process.argv))
|
|
||||||
.option('size', {
|
|
||||||
alias: 's',
|
|
||||||
describe: 'Specify the size of the logo',
|
|
||||||
type: 'number',
|
|
||||||
demandOption: true,
|
|
||||||
})
|
|
||||||
.argv;
|
|
||||||
|
|
||||||
const size = argv.size;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const webpImage = './src/@dasig/images/logo.webp'
|
|
||||||
const avifImage = './src/@dasig/images/logo.avif'
|
|
||||||
const inputSrc = './src/images/logo.png'
|
|
||||||
|
|
||||||
const avifBuffer = await sharp(inputSrc).avif({ quality: 60 }).resize(size).toBuffer()
|
|
||||||
await sharp(avifBuffer).toFile(avifImage)
|
|
||||||
consola.success('Logo successfully optimized in Avif')
|
|
||||||
|
|
||||||
const webpBuffer = await sharp(inputSrc).webp({ quality: 75 }).resize(size).toBuffer()
|
|
||||||
await sharp(webpBuffer).toFile(webpImage)
|
|
||||||
consola.success('Logo successfully optimized in Webp')
|
|
||||||
} catch (error) {
|
|
||||||
consola.error('Error generating favicon:', error)
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
36
frontend/@dasig/scripts/node/optimizeLogo.ts
Normal file
36
frontend/@dasig/scripts/node/optimizeLogo.ts
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import { consola } from "consola";
|
||||||
|
import process from "node:process";
|
||||||
|
import sharp from "sharp";
|
||||||
|
import yargs from "yargs";
|
||||||
|
import { hideBin } from "yargs/helpers";
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const size = yargs(hideBin(process.argv)).option("size", {
|
||||||
|
alias: "s",
|
||||||
|
describe: "Specify the size of the logo",
|
||||||
|
type: "number",
|
||||||
|
demandOption: true,
|
||||||
|
}).argv.size;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const webpImage = "./@dasig/images/logo.webp";
|
||||||
|
const avifImage = "./@dasig/images/logo.avif";
|
||||||
|
const inputSrc = "./src/images/logo.png";
|
||||||
|
|
||||||
|
const avifBuffer = await sharp(inputSrc)
|
||||||
|
.avif({ quality: 60 })
|
||||||
|
.resize(size)
|
||||||
|
.toBuffer();
|
||||||
|
await sharp(avifBuffer).toFile(avifImage);
|
||||||
|
consola.success("Logo successfully optimized in Avif");
|
||||||
|
|
||||||
|
const webpBuffer = await sharp(inputSrc)
|
||||||
|
.webp({ quality: 75 })
|
||||||
|
.resize(size)
|
||||||
|
.toBuffer();
|
||||||
|
await sharp(webpBuffer).toFile(webpImage);
|
||||||
|
consola.success("Logo successfully optimized in Webp");
|
||||||
|
} catch (error) {
|
||||||
|
consola.error("Error generating favicon:", error);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
@ -1,12 +1,17 @@
|
||||||
FROM node:22-alpine AS build
|
FROM denoland/deno:alpine AS build
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package*.json ./
|
COPY package*.json deno.lock ./
|
||||||
RUN corepack enable
|
RUN deno install && deno install --allow-scripts=npm:sharp,npm:@parcel/watcher
|
||||||
RUN pnpm install
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN pnpm build
|
ENV NODE_ENV=production
|
||||||
|
RUN deno task build
|
||||||
|
|
||||||
FROM nginx:alpine AS runtime
|
# FROM nginx:alpine AS runtime
|
||||||
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
# COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY --from=build /app/dist /usr/share/nginx/html
|
# COPY --from=build /app/.output/public /usr/share/nginx/html
|
||||||
EXPOSE 8080
|
# EXPOSE 8080
|
||||||
|
|
||||||
|
FROM denoland/deno:alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build /app .
|
||||||
|
CMD ["deno", "run", "--allow-env", "--allow-net", "--allow-read", ".output/server/index.mjs"]
|
||||||
|
|
@ -1,11 +1,13 @@
|
||||||
|
.SILENT:
|
||||||
|
|
||||||
all:
|
all:
|
||||||
deno install && deno install --allow-scripts=npm:sharp,npm:@parcel/watcher
|
deno install && deno install --allow-scripts=npm:sharp,npm:@parcel/watcher
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
deno run dev
|
deno task dev
|
||||||
|
|
||||||
build:
|
build:
|
||||||
deno run build
|
deno task build && PORT=9000 deno run --allow-env --allow-read --allow-net .output/server/index.mjs &
|
||||||
|
|
||||||
update:
|
update:
|
||||||
deno update
|
deno update
|
||||||
|
|
@ -17,11 +19,11 @@ podman:
|
||||||
podman-compose up -d
|
podman-compose up -d
|
||||||
|
|
||||||
favicon:
|
favicon:
|
||||||
deno ./src/@dasig/scripts/node/generateFavicon.js
|
deno --allow-env --allow-read --allow-ffi ./@dasig/scripts/node/generateFavicon.ts
|
||||||
|
|
||||||
logo:
|
logo:
|
||||||
deno ./src/@dasig/scripts/node/optimizeLogo.js --size $(size)
|
deno --allow-env --allow-read --allow-ffi ./@dasig/scripts/node/optimizeLogo.ts --size $(size)
|
||||||
|
|
||||||
image:
|
image:
|
||||||
deno ./src/@dasig/scripts/node/optimizeImage.js --name $(name) --size $(size)
|
deno --allow-env --allow-read --allow-ffi ./@dasig/scripts/node/optimizeImage.ts --name $(name) --size $(size)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { defineConfig } from '@solidjs/start/config'
|
import { defineConfig } from '@solidjs/start/config'
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
ssr: false,
|
ssr: true,
|
||||||
server: {
|
// server: {
|
||||||
static: true,
|
// static: true,
|
||||||
prerender: {
|
// prerender: {
|
||||||
crawlLinks: true,
|
// crawlLinks: true,
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 367 B |
Loading…
Add table
Add a link
Reference in a new issue