Skip to content

Commit

Permalink
chore(deps): updates
Browse files Browse the repository at this point in the history
  • Loading branch information
morlay committed Feb 23, 2024
1 parent ecc70c9 commit 9cd25ed
Show file tree
Hide file tree
Showing 143 changed files with 9,889 additions and 9,812 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ build.app:
cp ./public/vuekit/index.html ./public/vuekit/404.html

preview:
$(VITE) preview
$(VITE) preview --host=127.0.0.1

build.pkg:
$(TURBO) run build
Expand Down
28 changes: 0 additions & 28 deletions biome.json

This file was deleted.

Binary file modified bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions nodedevpkg/vue-vite-presets/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@innoai-tech/vue-vite-presets",
"version": "0.8.0",
"version": "0.8.1",
"monobundle": {
"pipeline": {
"test": false
Expand All @@ -11,13 +11,13 @@
},
"dependencies": {
"@innoai-tech/lodash": "^0.2.1",
"@innoai-tech/purebundle": "^0.2.12",
"@innoai-tech/purebundle": "^0.3.0",
"@mapbox/rehype-prism": "^0.9.0",
"@mdx-js/rollup": "^3.0.1",
"@vitejs/plugin-vue": "^5.0.4",
"hastscript": "^9.0.0",
"unist-util-visit": "^5.0.0",
"vite": "^5.1.3",
"vite": "^5.1.4",
"vite-plugin-pages": "^0.32.0",
"vite-tsconfig-paths": "^4.3.1"
},
Expand Down Expand Up @@ -48,7 +48,7 @@
"directory": "nodedevpkg/vue-vite-presets"
},
"scripts": {
"lint": "bunx --bun @biomejs/biome check --apply .",
"lint": "bunx --bun prettier --write . ",
"build": "bunx --bun monobundle",
"prepublishOnly": "bun run build"
},
Expand Down
147 changes: 75 additions & 72 deletions nodedevpkg/vue-vite-presets/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,83 +1,86 @@
import { resolve } from "path";
import {
type PluginOption,
type UserConfig,
searchForWorkspaceRoot,
type PluginOption,
type UserConfig,
searchForWorkspaceRoot,
} from "vite";
import tsconfigPaths from "vite-tsconfig-paths";

export interface AppConfig {
enableBaseHref?: boolean;
buildWithPlaceHolder?: boolean;
enableBaseHref?: boolean;
buildWithPlaceHolder?: boolean;
}

export const app = (
appName: string,
appConfig: AppConfig = {},
appName: string,
appConfig: AppConfig = {},
): PluginOption[] => {
(process.env as any).APP_VERSION = "__VERSION__";

const viteConfigRoot = searchForWorkspaceRoot(".");

let userConfig: UserConfig;

return [
{
name: "vite-presets/app",
config(c, { command }) {
userConfig = c;

c.base = appConfig.enableBaseHref
? appConfig.buildWithPlaceHolder && command === "build"
? "/__APP_BASE_HREF__/"
: `/${appName}/`
: "/";

c.publicDir = appConfig.enableBaseHref ? c.base : false;

c.root = resolve(viteConfigRoot, `./webapp/${appName}`);

c.build = c.build ?? {};

c.build.outDir = resolve(viteConfigRoot, `./public/${appName}`);
c.build.emptyOutDir = true;

c.build.rollupOptions = c.build.rollupOptions ?? {};
c.build.rollupOptions.external = c.build.rollupOptions.external ?? [
"csstype",
];

c.build.assetsDir = c.build.assetsDir ?? "__built__";

// to avoid some filename starts with _
c.build.rollupOptions.output = {
assetFileNames: `${c.build.assetsDir}/[name].[hash][extname]`,
entryFileNames: `${c.build.assetsDir}/[name].[hash].entry.js`,
chunkFileNames: `${c.build.assetsDir}/[name].[hash].chunk.js`,
};

c.resolve = c.resolve ?? {};
c.resolve.alias = c.resolve.alias ?? ({} as Record<string, string>);

c.esbuild = {
jsxDev: c.mode !== "production",
};
},

transformIndexHtml(html: string) {
return {
html: html,
tags: [
{
tag: "base",
attrs: {
href: userConfig.base ?? "/",
},
},
],
};
},
},
tsconfigPaths({}) as PluginOption,
];
(process.env as any).APP_VERSION = "__VERSION__";

const viteConfigRoot = searchForWorkspaceRoot(".");

let userConfig: UserConfig;

return [
{
name: "vite-presets/app",
config(c, { command }) {
userConfig = c;

c.base = appConfig.enableBaseHref
? appConfig.buildWithPlaceHolder && command === "build"
? "/__APP_BASE_HREF__/"
: `/${appName}/`
: "/";

c.publicDir = appConfig.enableBaseHref ? c.base : false;

c.root = resolve(viteConfigRoot, `./webapp/${appName}`);

c.build = c.build ?? {};

c.build.outDir = resolve(
viteConfigRoot,
c.build.outDir ?? `./public/${appName}`,
);
c.build.emptyOutDir = true;

c.build.rollupOptions = c.build.rollupOptions ?? {};
c.build.rollupOptions.external = c.build.rollupOptions.external ?? [
"csstype",
];

c.build.assetsDir = c.build.assetsDir ?? "__built__";

// to avoid some filename starts with _
c.build.rollupOptions.output = {
assetFileNames: `${c.build.assetsDir}/[name].[hash][extname]`,
entryFileNames: `${c.build.assetsDir}/[name].[hash].entry.js`,
chunkFileNames: `${c.build.assetsDir}/[name].[hash].chunk.js`,
};

c.resolve = c.resolve ?? {};
c.resolve.alias = c.resolve.alias ?? ({} as Record<string, string>);

c.esbuild = {
jsxDev: c.mode !== "production",
};
},

transformIndexHtml(html: string) {
return {
html: html,
tags: [
{
tag: "base",
attrs: {
href: userConfig.base ?? "/",
},
},
],
};
},
},
tsconfigPaths({}) as PluginOption,
];
};
116 changes: 58 additions & 58 deletions nodedevpkg/vue-vite-presets/src/chunkCleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,71 +2,71 @@ import { transform } from "@innoai-tech/purebundle";
import { type Plugin, createFilter } from "vite";

export const chunkCleanup = (
opt: {
annotatePure?: boolean;
minify?: boolean;
env?: {
targets?: string | { [K: string]: string };
mode?: string;
coreJs?: string;
exclude?: string[];
include?: string[];
};
} = {},
opt: {
annotatePure?: boolean;
minify?: boolean;
env?: {
targets?: string | { [K: string]: string };
mode?: string;
coreJs?: string;
exclude?: string[];
include?: string[];
};
} = {},
): Plugin => {
const isJSOrLike = createFilter([
/\.vue$/,
/\.mdx$/,
/\.tsx?$/,
/\.mjs$/,
/\.jsx?$/,
]);
const isJSOrLike = createFilter([
/\.vue$/,
/\.mdx$/,
/\.tsx?$/,
/\.mjs$/,
/\.jsx?$/,
]);

return {
name: "monobundle/chunk-cleanup",
enforce: "post",
apply: "build",
return {
name: "monobundle/chunk-cleanup",
enforce: "post",
apply: "build",

config(c) {
c.build = c.build ?? {};
config(c) {
c.build = c.build ?? {};

if (opt.minify) {
// when minify set, disable default esbuild minify
c.build.minify = false;
}
},
if (opt.minify) {
// when minify set, disable default esbuild minify
c.build.minify = false;
}
},

async transform(code, id) {
if (!isJSOrLike(id)) {
return null;
}
async transform(code, id) {
if (!isJSOrLike(id)) {
return null;
}

if (id.includes("/node_modules/core-js/")) {
return null;
}
if (id.includes("/node_modules/core-js/")) {
return null;
}

// only for build
const result = await transform(code, {
filename: id,
env: opt.env ?? { targets: "defaults" },
minify: false,
});
// only for build
const result = await transform(code, {
filename: id,
env: opt.env ?? { targets: "defaults" },
minify: false,
});

return (
result.code && {
code: result.code,
map: result.map || null,
}
);
},
return (
result.code && {
code: result.code,
map: result.map || null,
}
);
},

async renderChunk(code: string) {
return (
await transform(code, {
minify: opt.minify ?? false,
annotatePure: opt.annotatePure ?? true,
})
).code;
},
};
async renderChunk(code: string) {
return (
await transform(code, {
minify: opt.minify ?? false,
annotatePure: opt.annotatePure ?? true,
})
).code;
},
};
};
Loading

0 comments on commit 9cd25ed

Please sign in to comment.