@lntvow/vite-plugin 0.0.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/README.md +1 -0
- package/dist/index.cjs +41 -0
- package/dist/index.d.cts +17 -0
- package/dist/index.d.mts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.mjs +33 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# vite-plugin
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const dayjs = require('dayjs');
|
|
4
|
+
const utc = require('dayjs/plugin/utc.js');
|
|
5
|
+
const timezone = require('dayjs/plugin/timezone.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
8
|
+
|
|
9
|
+
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
10
|
+
const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
|
|
11
|
+
const timezone__default = /*#__PURE__*/_interopDefaultCompat(timezone);
|
|
12
|
+
|
|
13
|
+
dayjs__default.extend(utc__default);
|
|
14
|
+
dayjs__default.extend(timezone__default);
|
|
15
|
+
function vitePluginLogs(options = {}) {
|
|
16
|
+
const { name, version } = options;
|
|
17
|
+
return {
|
|
18
|
+
name: "vite-plugin-logs",
|
|
19
|
+
transform(code, id) {
|
|
20
|
+
if (id.endsWith("src/main.ts")) {
|
|
21
|
+
const time = dayjs__default().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");
|
|
22
|
+
return {
|
|
23
|
+
code: `
|
|
24
|
+
|
|
25
|
+
import { log } from '@lntvow/utils';
|
|
26
|
+
|
|
27
|
+
${code}
|
|
28
|
+
|
|
29
|
+
import('../package.json').then(res => {
|
|
30
|
+
localStorage.setItem(${name || `'LNTVOW_VERSION'`}, JSON.stringify(['${time}', ${version || "res.version"}]))
|
|
31
|
+
log('version', '${time}', ${version || "res.version"})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
`
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
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 };
|
package/dist/index.d.mts
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 };
|
package/dist/index.d.ts
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 };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
3
|
+
import timezone from 'dayjs/plugin/timezone.js';
|
|
4
|
+
|
|
5
|
+
dayjs.extend(utc);
|
|
6
|
+
dayjs.extend(timezone);
|
|
7
|
+
function vitePluginLogs(options = {}) {
|
|
8
|
+
const { name, version } = options;
|
|
9
|
+
return {
|
|
10
|
+
name: "vite-plugin-logs",
|
|
11
|
+
transform(code, id) {
|
|
12
|
+
if (id.endsWith("src/main.ts")) {
|
|
13
|
+
const time = dayjs().tz("Asia/Shanghai").format("YYYY-MM-DD HH:mm:ss");
|
|
14
|
+
return {
|
|
15
|
+
code: `
|
|
16
|
+
|
|
17
|
+
import { log } from '@lntvow/utils';
|
|
18
|
+
|
|
19
|
+
${code}
|
|
20
|
+
|
|
21
|
+
import('../package.json').then(res => {
|
|
22
|
+
localStorage.setItem(${name || `'LNTVOW_VERSION'`}, JSON.stringify(['${time}', ${version || "res.version"}]))
|
|
23
|
+
log('version', '${time}', ${version || "res.version"})
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
`
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { vitePluginLogs as Logs };
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lntvow/vite-plugin",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "vite插件",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "lntvow",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@lntvow/utils": "^1.8.5",
|
|
13
|
+
"dayjs": "^1.11.10"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"unbuild": "^2.0.0",
|
|
17
|
+
"@lntvow/eslint-config": "^8.2.18",
|
|
18
|
+
"bumpp": "^9.1.1",
|
|
19
|
+
"commitizen": "^4.3.0",
|
|
20
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
21
|
+
"typescript": "^5.0.4"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"vite": "^4.4.6"
|
|
25
|
+
},
|
|
26
|
+
"resolutions": {
|
|
27
|
+
"bin-wrapper": "npm:bin-wrapper-china"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "unbuild",
|
|
31
|
+
"commit": "git add . && git-cz && git push",
|
|
32
|
+
"rimraf": "rimraf ./node_modules/",
|
|
33
|
+
"release": "git add . && bumpp package.json --all --commit --no-tag --push"
|
|
34
|
+
}
|
|
35
|
+
}
|