forked from naskya/firefish
refactor: make client
and sw
ES modules
This commit is contained in:
parent
e4bcd23f9d
commit
4bf63a73e0
7 changed files with 30 additions and 21 deletions
|
@ -8,7 +8,6 @@ const replace = require("gulp-replace");
|
||||||
const terser = require("gulp-terser");
|
const terser = require("gulp-terser");
|
||||||
const cssnano = require("gulp-cssnano");
|
const cssnano = require("gulp-cssnano");
|
||||||
|
|
||||||
const locales = require("./locales");
|
|
||||||
const meta = require("./package.json");
|
const meta = require("./package.json");
|
||||||
|
|
||||||
gulp.task("copy:backend:views", () =>
|
gulp.task("copy:backend:views", () =>
|
||||||
|
@ -29,8 +28,9 @@ gulp.task("copy:client:fonts", () =>
|
||||||
.pipe(gulp.dest("./built/_client_dist_/fonts/")),
|
.pipe(gulp.dest("./built/_client_dist_/fonts/")),
|
||||||
);
|
);
|
||||||
|
|
||||||
gulp.task("copy:client:locales", (cb) => {
|
gulp.task("copy:client:locales", async (cb) => {
|
||||||
fs.mkdirSync("./built/_client_dist_/locales", { recursive: true });
|
fs.mkdirSync("./built/_client_dist_/locales", { recursive: true });
|
||||||
|
const { default: locales } = await import("./locales/index.mjs");
|
||||||
|
|
||||||
const v = { _version_: meta.version };
|
const v = { _version_: meta.version };
|
||||||
|
|
||||||
|
@ -45,7 +45,9 @@ gulp.task("copy:client:locales", (cb) => {
|
||||||
cb();
|
cb();
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task("build:backend:script", () => {
|
gulp.task("build:backend:script", async () => {
|
||||||
|
const { default: locales } = await import("./locales/index.mjs");
|
||||||
|
|
||||||
return gulp
|
return gulp
|
||||||
.src([
|
.src([
|
||||||
"./packages/backend/src/server/web/boot.js",
|
"./packages/backend/src/server/web/boot.js",
|
||||||
|
|
|
@ -2,8 +2,14 @@
|
||||||
* Languages Loader
|
* Languages Loader
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const fs = require("fs");
|
import fs from "node:fs";
|
||||||
const yaml = require("js-yaml");
|
import yaml from "js-yaml";
|
||||||
|
|
||||||
|
import { dirname } from "node:path";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
|
||||||
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const languages = [];
|
const languages = [];
|
||||||
const languages_custom = [];
|
const languages_custom = [];
|
||||||
|
|
||||||
|
@ -66,16 +72,17 @@ const locales_custom = languages_custom.reduce(
|
||||||
);
|
);
|
||||||
Object.assign(locales, locales_custom);
|
Object.assign(locales, locales_custom);
|
||||||
|
|
||||||
module.exports = Object.entries(locales).reduce(
|
export default Object.entries(locales).reduce(
|
||||||
(a, [k, v]) => (
|
(a, [k, v]) => (
|
||||||
(a[k] = (() => {
|
(a[k] = (() => {
|
||||||
const [lang] = k.split("-");
|
const [lang] = k.split("-");
|
||||||
return k === "en-US" ? v :
|
return k === "en-US"
|
||||||
merge(
|
? v
|
||||||
locales["en-US"],
|
: merge(
|
||||||
locales[`${lang}-${primaries[lang]}`] || {},
|
locales["en-US"],
|
||||||
v,
|
locales[`${lang}-${primaries[lang]}`] || {},
|
||||||
);
|
v,
|
||||||
|
);
|
||||||
})()),
|
})()),
|
||||||
a
|
a
|
||||||
),
|
),
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "client",
|
"name": "client",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "pnpm vite build --watch --mode development",
|
"watch": "pnpm vite build --watch --mode development",
|
||||||
"build": "pnpm vite build",
|
"build": "pnpm vite build",
|
||||||
|
|
|
@ -2,10 +2,10 @@ import * as fs from "fs";
|
||||||
import pluginVue from "@vitejs/plugin-vue";
|
import pluginVue from "@vitejs/plugin-vue";
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
|
|
||||||
import viteCompression from "vite-plugin-compression";
|
import locales from "../../locales/index.mjs";
|
||||||
import locales from "../../locales";
|
import meta from "../../package.json" assert { type: "json" };
|
||||||
import meta from "../../package.json";
|
|
||||||
import pluginJson5 from "./vite.json5";
|
import pluginJson5 from "./vite.json5";
|
||||||
|
import viteCompression from "vite-plugin-compression";
|
||||||
|
|
||||||
const extensions = [
|
const extensions = [
|
||||||
".ts",
|
".ts",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "sw",
|
"name": "sw",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "pnpm vite build --emptyOutDir",
|
"build": "pnpm vite build --emptyOutDir",
|
||||||
"build:debug": "pnpm run build",
|
"build:debug": "pnpm run build",
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"noLib": false,
|
"noLib": false,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"strictNullChecks": true,
|
"strictNullChecks": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
|
@ -23,10 +24,7 @@
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"]
|
"@/*": ["./src/*"]
|
||||||
},
|
},
|
||||||
"typeRoots": [
|
"typeRoots": ["node_modules/@types", "@types"],
|
||||||
"node_modules/@types",
|
|
||||||
"@types",
|
|
||||||
],
|
|
||||||
"lib": ["esnext", "webworker"]
|
"lib": ["esnext", "webworker"]
|
||||||
},
|
},
|
||||||
"compileOnSave": false,
|
"compileOnSave": false,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { defineConfig } from "vite";
|
import { defineConfig } from "vite";
|
||||||
const locales = require("../../locales");
|
import locales from "../../locales/index.mjs";
|
||||||
const meta = require("../../package.json");
|
import meta from "../../package.json" assert { type: "json" };
|
||||||
|
|
||||||
const isProduction = process.env.NODE_ENV === "production";
|
const isProduction = process.env.NODE_ENV === "production";
|
||||||
import viteCompression from "vite-plugin-compression";
|
import viteCompression from "vite-plugin-compression";
|
||||||
|
|
Loading…
Reference in a new issue