Commit 34231424 by 杨明

npm

1 parent 81826afd
......@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-28 10:33:29
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 10:33:38
* @LastEditTime: 2023-11-28 15:44:33
* @FilePath: \rollup_demo\.eslintrc.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -11,6 +11,7 @@ module.exports = {
env: {
node: true
},
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 7,
sourceType: 'module'
......
{
"liveServer.settings.port": 9529
}
......@@ -90,6 +90,12 @@
"picomatch": "^2.2.2"
}
},
"@types/estree": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz",
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
"dev": true
},
"@types/node": {
"version": "20.10.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.0.tgz",
......@@ -434,6 +440,15 @@
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true
},
"is-reference": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz",
"integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==",
"dev": true,
"requires": {
"@types/estree": "*"
}
},
"isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
......@@ -681,6 +696,27 @@
}
}
},
"rollup-plugin-commonjs": {
"version": "10.1.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-commonjs/-/rollup-plugin-commonjs-10.1.0.tgz",
"integrity": "sha512-jlXbjZSQg8EIeAAvepNwhJj++qJWNJw1Cl0YnOqKtP5Djx+fFGkp3WRh+W0ASCaFG5w1jhmzDxgu3SJuVxPF4Q==",
"dev": true,
"requires": {
"estree-walker": "^0.6.1",
"is-reference": "^1.1.2",
"magic-string": "^0.25.2",
"resolve": "^1.11.0",
"rollup-pluginutils": "^2.8.1"
},
"dependencies": {
"estree-walker": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz",
"integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==",
"dev": true
}
}
},
"rollup-plugin-livereload": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/rollup-plugin-livereload/-/rollup-plugin-livereload-2.0.5.tgz",
......@@ -918,4 +954,4 @@
"dev": true
}
}
}
}
\ No newline at end of file
......@@ -2,24 +2,26 @@
"name": "glsx-tracker-javascript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"main": "dist/glsx-tracker-javascript.cjs.js",
"module": "dist/glsx-tracker-javascript.es.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "cross-env NODE_ENV=development rollup -c -w",
"build": "cross-env NODE_ENV=produaction rollup -c"
"dev": "rollup -c -w",
"build": " rollup -c",
"release": "rollup -c && npm publish"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"cross-env": "^7.0.3",
"rollup": "^2.10.9",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-livereload": "^2.0.5",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-serve": "^1.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.31.2",
"rollup": "^2.10.9",
"typescript": "^4.9.5"
}
}
}
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-24 17:29:53
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-27 11:18:25
* @LastEditTime: 2023-11-28 16:29:42
* @FilePath: \rollup_demo\public\index.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
......@@ -14,6 +14,6 @@
<title>Document</title>
</head>
<body>
<script src="../dist/glsx-tracker-javascript.js"></script>
<script src="../dist/glsx-tracker-javascript.umd.js"></script>
</body>
</html>
......@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-24 16:44:09
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 14:22:09
* @LastEditTime: 2023-11-28 16:25:44
* @FilePath: \rollup_demo\rollup.config.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -13,17 +13,24 @@ import livereload from 'rollup-plugin-livereload'
import { terser } from 'rollup-plugin-terser'
import resolve from 'rollup-plugin-node-resolve'
import repacle from 'rollup-plugin-replace'
import commonjs from 'rollup-plugin-commonjs'
import { name } from './package.json'
const isDev = () => {
return process.env.NODE_ENV === 'development'
}
export default {
input: './src/main.ts',
output: {
file: path.resolve(__dirname, `./dist/${name}.js`),
format: 'umd',
sourcemap: false
},
output: [
{
file: path.resolve(__dirname, `./dist/${name}.umd.js`),
format: 'umd',
name
},
{
file: path.resolve(__dirname, `./dist/${name}.es.js`),
format: 'es'
}
],
plugins: [
ts(),
......@@ -36,6 +43,7 @@ export default {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}),
resolve(['.js', '.ts']),
commonjs(),
isDev() && livereload(),
isDev() &&
serve({
......
......@@ -2,11 +2,16 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-24 17:28:02
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 14:14:11
* @LastEditTime: 2023-11-28 16:09:44
* @FilePath: \rollup_demo\src\main.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import Request from './modules/request'
const request = new Request('https://www.xxx.com', 'ajax')
console.log(request.url)
class Tracker {
init() {
console.log('init')
}
}
export default Tracker
......@@ -2,11 +2,12 @@
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-27 11:13:22
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 10:15:18
* @LastEditTime: 2023-11-28 15:25:36
* @FilePath: \rollup_demo\src\modules\request.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import { requestType } from 'request'
import utils from '../utils/helper'
class Request {
public url: string
public method: requestType
......@@ -15,4 +16,5 @@ class Request {
this.method = method
}
}
console.log(utils.dateFormat(new Date()))
export default Request
/*
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-11-28 14:20:48
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2023-11-28 15:25:20
* @FilePath: \glsx-tracker-javascript\src\utils\helper.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
export default {
dateFormat(timestamp: number | string | Date, format = 'YYYY-MM-DD HH:mm:ss'): string {
var date = new Date(timestamp)
function fixedTwo(value: number): string {
return value < 10 ? '0' + value : String(value)
}
var showTime = format
if (showTime.includes('SSS')) {
const S = date.getMilliseconds()
showTime = showTime.replace('SSS', '0'.repeat(3 - String(S).length) + S)
}
if (showTime.includes('YY')) {
const Y = date.getFullYear()
showTime = showTime.includes('YYYY') ? showTime.replace('YYYY', String(Y)) : showTime.replace('YY', String(Y).slice(2, 4))
}
if (showTime.includes('M')) {
const M = date.getMonth() + 1
showTime = showTime.includes('MM') ? showTime.replace('MM', fixedTwo(M)) : showTime.replace('M', String(M))
}
if (showTime.includes('D')) {
const D = date.getDate()
showTime = showTime.includes('DD') ? showTime.replace('DD', fixedTwo(D)) : showTime.replace('D', String(D))
}
if (showTime.includes('H')) {
const H = date.getHours()
showTime = showTime.includes('HH') ? showTime.replace('HH', fixedTwo(H)) : showTime.replace('H', String(H))
}
if (showTime.includes('m')) {
var m = date.getMinutes()
showTime = showTime.includes('mm') ? showTime.replace('mm', fixedTwo(m)) : showTime.replace('m', String(m))
}
if (showTime.includes('s')) {
var s = date.getSeconds()
showTime = showTime.includes('ss') ? showTime.replace('ss', fixedTwo(s)) : showTime.replace('s', String(s))
}
return showTime
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!