@lntvow/vite-plugin 0.0.16 → 0.0.17
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.cjs +10 -0
- package/dist/index.d.cts +17 -0
- package/package.json +1 -1
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";const m=require("node:path"),a=require("node:fs"),r=require("dayjs"),c=require("dayjs/plugin/utc.js"),f=require("dayjs/plugin/timezone.js");function _interopDefaultCompat(t){return t&&typeof t=="object"&&"default"in t?t.default:t}const m__default=_interopDefaultCompat(m),a__default=_interopDefaultCompat(a),r__default=_interopDefaultCompat(r),c__default=_interopDefaultCompat(c),f__default=_interopDefaultCompat(f);r__default.extend(c__default),r__default.extend(f__default);function vitePluginLogs(t={}){const{name:s="LNTVOW_VERSION"}=t;let e=t.version;if(!e)try{const n=a__default.readFileSync(m__default.resolve(process.cwd(),"package.json"),"utf8");e=JSON.parse(n).version}catch{throw new Error("package.json not found")}return{name:"vite-plugin-logs",transform(n,i){if(i.endsWith("src/main.ts")){const o=r__default().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");return{code:`
|
|
2
|
+
|
|
3
|
+
import { log } from '@lntvow/utils';
|
|
4
|
+
|
|
5
|
+
${n}
|
|
6
|
+
|
|
7
|
+
localStorage.setItem('${s}', JSON.stringify(['${o}', '${e}']))
|
|
8
|
+
log('version', '${o}', '${e}')
|
|
9
|
+
|
|
10
|
+
`}}}}}exports.Logs=vitePluginLogs;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
declare function vitePluginLogs(options?: Options): Plugin;
|
|
4
|
+
interface Options {
|
|
5
|
+
/**
|
|
6
|
+
* @description localStorage key
|
|
7
|
+
* @default LNTVOW_VERSION
|
|
8
|
+
*/
|
|
9
|
+
name?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @description 版本号
|
|
12
|
+
* @default 默认读取package.json的version
|
|
13
|
+
*/
|
|
14
|
+
version?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { vitePluginLogs as Logs };
|