@octohash/vite-config 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +8 -0
- package/dist/index.mjs +25 -17
- package/package.json +23 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AliasOptions, PluginOption, UserConfig } from "vite";
|
|
2
2
|
import { PluginOptions } from "@intlify/unplugin-vue-i18n";
|
|
3
|
+
import { VitePluginConfig } from "unocss/vite";
|
|
3
4
|
import { Options } from "unplugin-auto-import/types";
|
|
4
5
|
import { Options as Options$1 } from "unplugin-vue-components";
|
|
5
6
|
import { VitePluginVueDevToolsOptions } from "vite-plugin-vue-devtools";
|
|
@@ -77,6 +78,13 @@ interface AppPluginOptions {
|
|
|
77
78
|
* @default true
|
|
78
79
|
*/
|
|
79
80
|
metadata?: boolean | MetadataPluginOptions;
|
|
81
|
+
/**
|
|
82
|
+
* https://unocss.dev/integrations/vite
|
|
83
|
+
* Enable UnoCSS when `unocss` is installed.
|
|
84
|
+
*
|
|
85
|
+
* @default auto-detect based on the dependencies
|
|
86
|
+
*/
|
|
87
|
+
unocss?: boolean | VitePluginConfig;
|
|
80
88
|
}
|
|
81
89
|
interface OptionsVue {
|
|
82
90
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -6668,6 +6668,22 @@ const LOCK_FILES = [
|
|
|
6668
6668
|
"bun.lockb"
|
|
6669
6669
|
];
|
|
6670
6670
|
//#endregion
|
|
6671
|
+
//#region src/ensure.ts
|
|
6672
|
+
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
6673
|
+
const isCwdInScope = isPackageExists("@octohash/vite-config");
|
|
6674
|
+
function isPackageInScope(name) {
|
|
6675
|
+
return isPackageExists(name, { paths: [scopeUrl] });
|
|
6676
|
+
}
|
|
6677
|
+
async function ensurePackages(packages, dev = true) {
|
|
6678
|
+
if (process$1.env.CI || process$1.stdout.isTTY === false || isCwdInScope === false) return;
|
|
6679
|
+
const pkgs = packages.filter((i) => i && !isPackageInScope(i) && !isPackageExists(i));
|
|
6680
|
+
if (pkgs.length === 0) return;
|
|
6681
|
+
if (await (await import("@clack/prompts")).confirm({ message: `${pkgs.length === 1 ? "Package is" : "Packages are"} required for this config: ${pkgs.join(", ")}. Do you want to install them?` })) {
|
|
6682
|
+
const { installPackage } = await import("@antfu/install-pkg");
|
|
6683
|
+
await installPackage(pkgs, { dev });
|
|
6684
|
+
}
|
|
6685
|
+
}
|
|
6686
|
+
//#endregion
|
|
6671
6687
|
//#region node_modules/.pnpm/empathic@2.0.1/node_modules/empathic/resolve.mjs
|
|
6672
6688
|
var import_cjs = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6673
6689
|
var isMergeableObject = function isMergeableObject(value) {
|
|
@@ -8417,22 +8433,6 @@ async function MetadataPlugin(options) {
|
|
|
8417
8433
|
};
|
|
8418
8434
|
}
|
|
8419
8435
|
//#endregion
|
|
8420
|
-
//#region src/ensure.ts
|
|
8421
|
-
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
8422
|
-
const isCwdInScope = isPackageExists("@octohash/vite-config");
|
|
8423
|
-
function isPackageInScope(name) {
|
|
8424
|
-
return isPackageExists(name, { paths: [scopeUrl] });
|
|
8425
|
-
}
|
|
8426
|
-
async function ensurePackages(packages, dev = true) {
|
|
8427
|
-
if (process$1.env.CI || process$1.stdout.isTTY === false || isCwdInScope === false) return;
|
|
8428
|
-
const pkgs = packages.filter((i) => i && !isPackageInScope(i) && !isPackageExists(i));
|
|
8429
|
-
if (pkgs.length === 0) return;
|
|
8430
|
-
if (await (await import("@clack/prompts")).confirm({ message: `${pkgs.length === 1 ? "Package is" : "Packages are"} required for this config: ${pkgs.join(", ")}. Do you want to install them?` })) {
|
|
8431
|
-
const { installPackage } = await import("@antfu/install-pkg");
|
|
8432
|
-
await installPackage(pkgs, { dev });
|
|
8433
|
-
}
|
|
8434
|
-
}
|
|
8435
|
-
//#endregion
|
|
8436
8436
|
//#region src/plugins/vue.ts
|
|
8437
8437
|
async function loadVuePlugins(options) {
|
|
8438
8438
|
const { isBuild } = options;
|
|
@@ -8528,7 +8528,8 @@ async function resolveUIComponentResolvers() {
|
|
|
8528
8528
|
//#endregion
|
|
8529
8529
|
//#region src/plugins/index.ts
|
|
8530
8530
|
async function loadAppPlugins(options) {
|
|
8531
|
-
const { dynamicBase, appLoading = true, metadata = true, vue } = options;
|
|
8531
|
+
const { dynamicBase, appLoading = true, metadata = true, unocss = false, vue } = options;
|
|
8532
|
+
await ensurePackages([unocss ? "unocss" : void 0]);
|
|
8532
8533
|
const plugins = await loadCommonPlugins(options);
|
|
8533
8534
|
plugins.push(await loadPlugins([
|
|
8534
8535
|
{
|
|
@@ -8550,12 +8551,19 @@ async function loadAppPlugins(options) {
|
|
|
8550
8551
|
}
|
|
8551
8552
|
]));
|
|
8552
8553
|
if (vue) plugins.push(await loadVuePlugins(options));
|
|
8554
|
+
plugins.push(await loadPlugins([{
|
|
8555
|
+
condition: !!unocss,
|
|
8556
|
+
plugins: async () => {
|
|
8557
|
+
return [(await import("unocss/vite")).default(typeof unocss === "boolean" ? void 0 : unocss)];
|
|
8558
|
+
}
|
|
8559
|
+
}]));
|
|
8553
8560
|
return plugins;
|
|
8554
8561
|
}
|
|
8555
8562
|
//#endregion
|
|
8556
8563
|
//#region src/index.ts
|
|
8557
8564
|
function defineConfig(options) {
|
|
8558
8565
|
const resolved = {
|
|
8566
|
+
unocss: isPackageExists("unocss"),
|
|
8559
8567
|
vue: VUE_PACKAGES.some((pkg) => isPackageExists(pkg)),
|
|
8560
8568
|
...options
|
|
8561
8569
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octohash/vite-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"description": "Opinionated Vite config preset.",
|
|
6
6
|
"author": "jinghaihan",
|
|
7
7
|
"license": "MIT",
|
|
@@ -29,8 +29,25 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"peerDependencies": {
|
|
32
|
+
"@intlify/unplugin-vue-i18n": ">=11.0.0",
|
|
32
33
|
"@unhead/vue": ">=2.0.0",
|
|
33
|
-
"
|
|
34
|
+
"unocss": ">=66.0.0",
|
|
35
|
+
"vite": ">=8.0.0",
|
|
36
|
+
"vite-plugin-vue-devtools": ">=8.0.0"
|
|
37
|
+
},
|
|
38
|
+
"peerDependenciesMeta": {
|
|
39
|
+
"@intlify/unplugin-vue-i18n": {
|
|
40
|
+
"optional": true
|
|
41
|
+
},
|
|
42
|
+
"@unhead/vue": {
|
|
43
|
+
"optional": true
|
|
44
|
+
},
|
|
45
|
+
"unocss": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"vite-plugin-vue-devtools": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
34
51
|
},
|
|
35
52
|
"dependencies": {
|
|
36
53
|
"unplugin-auto-import": "^21.0.0",
|
|
@@ -43,12 +60,9 @@
|
|
|
43
60
|
"unplugin-vue-components": "^32.1.0",
|
|
44
61
|
"vue-router": "^5.1.0"
|
|
45
62
|
},
|
|
46
|
-
"optionalDependencies": {
|
|
47
|
-
"@intlify/unplugin-vue-i18n": "^11.2.4",
|
|
48
|
-
"vite-plugin-vue-devtools": "^8.1.4"
|
|
49
|
-
},
|
|
50
63
|
"devDependencies": {
|
|
51
64
|
"tsdown": "^0.22.3",
|
|
65
|
+
"unocss": "^66.7.3",
|
|
52
66
|
"bumpp": "^11.1.0",
|
|
53
67
|
"nano-staged": "^1.0.2",
|
|
54
68
|
"pncat": "^0.12.0",
|
|
@@ -63,7 +77,9 @@
|
|
|
63
77
|
"@octohash/eslint-config": "^0.4.1",
|
|
64
78
|
"eslint": "^10.5.0",
|
|
65
79
|
"vitest": "^4.1.9",
|
|
66
|
-
"@types/node": "^26.0.1"
|
|
80
|
+
"@types/node": "^26.0.1",
|
|
81
|
+
"@intlify/unplugin-vue-i18n": "^11.2.4",
|
|
82
|
+
"vite-plugin-vue-devtools": "^8.1.4"
|
|
67
83
|
},
|
|
68
84
|
"simple-git-hooks": {
|
|
69
85
|
"pre-commit": "pnpm nano-staged"
|