提交 ceecefbf 编写于 作者: D duanlikang

chore: refactor project

上级 8cea37ff
......@@ -5,10 +5,12 @@
TODO
### 开发
#### 安装
1. 执行 `npm run bootstrap`安装相关依赖
#### Dev 开发
1. `npm install` 安装相关依赖
2. `npm run dev` 开启 Dev 服务
3. 浏览器访问 `http://localhost:3000/playground` 即可
1. `npm run dev:playground` 开启 Dev 服务
2. 浏览器访问 `http://localhost:3000/playground` 即可
#### Build
1. 执行 `npm run build`即可
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Dokit Web</title>
</head>
<body>
<div id="app"></div>
<script src="../../dist/dokit.js"></script>
<script>
dokit.init()
</script>
</body>
</html>
{
"packages": [
"packages/*"
],
"version": "0.0.0",
"npmClient": "npm",
"command": {
"publish": {
"allowBranch": [
"main",
"release"
],
"ignoreChanges": [
"lerna.json"
],
"registry": "https://registry.npmjs.org/"
},
"npmClientArgs": [
"--no-lockfile"
]
}
}
......@@ -4,15 +4,19 @@
"description": "a web toolkit powered by Dokit",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "node scripts/build.js",
"dev": "node scripts/dev.js"
"bootstrap": "npm install && lerna bootstrap",
"build": "lerna run build",
"dev": "lerna run dev",
"dev:playground": "node scripts/dev-playground.js & npm run dev",
"clean": "lerna clean --yes && rm -rf ./packages/**/package-lock.json",
"clean:lock": "rm -rf ./package-lock.json && rm -rf ./packages/**/package-lock.json"
},
"author": "caoenze",
"license": "ISC",
"devDependencies": {
"@vue/compiler-sfc": "^3.0.7",
"execa": "^5.0.0",
"lerna": "^4.0.0",
"less": "^4.1.1",
"open": "^8.0.6",
"rollup": "^2.41.1",
......@@ -24,6 +28,7 @@
"serve-handler": "^6.1.3"
},
"dependencies": {
"rollup-plugin-terser": "^7.0.2",
"vue": "^3.0.7"
}
}
# `utils`
> TODO: description
## Usage
```
const utils = require('utils');
// TODO: DEMONSTRATE API
```
'use strict';
const dokit = require('..');
const utils = require('..');
describe('dokit', () => {
describe('utils', () => {
it('needs tests');
});
{
"name": "@dokit/web-core",
"version": "0.0.0",
"description": "Dokit",
"keywords": [
"Dokit"
],
"author": "duanlikang <duanlikang@didichuxing.com>",
"homepage": "https://github.com/didi/DoraemonKit#readme",
"license": "ISC",
"main": "dist/main.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"registry": "https://registry.npm.taobao.org/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/didi/DoraemonKit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
"url": "https://github.com/didi/DoraemonKit/issues"
}
}
'use strict';
module.exports = utils;
function utils() {
// TODO
}
# `utils`
> TODO: description
## Usage
```
const utils = require('utils');
// TODO: DEMONSTRATE API
```
'use strict';
const utils = require('..');
describe('utils', () => {
it('needs tests');
});
{
"name": "@dokit/web-utils",
"version": "0.0.0",
"description": "Dokit",
"keywords": [
"Dokit"
],
"author": "duanlikang <duanlikang@didichuxing.com>",
"homepage": "https://github.com/didi/DoraemonKit#readme",
"license": "ISC",
"main": "dist/main.js",
"directories": {
"lib": "lib",
"test": "__tests__"
},
"files": [
"lib"
],
"publishConfig": {
"registry": "https://registry.npm.taobao.org/"
},
"repository": {
"type": "git",
"url": "git+https://github.com/didi/DoraemonKit.git"
},
"scripts": {
"test": "echo \"Error: run tests from root\" && exit 1"
},
"bugs": {
"url": "https://github.com/didi/DoraemonKit/issues"
}
}
'use strict';
module.exports = utils;
function utils() {
// TODO
}
# `web`
> TODO: description
## Usage
```
const web = require('web');
// TODO: DEMONSTRATE API
```
'use strict';
const web = require('..');
describe('web', () => {
it('needs tests');
});
{
"name": "@dokit/web",
"version": "0.0.0",
"description": "Dokit Web Main Entry",
"keywords": [
"Dokit"
],
"author": "duanlikang <duanlikang@didichuxing.com>",
"homepage": "http://dokit.cn",
"license": "ISC",
"main": "dist/web.js",
"files": [
"dist"
],
"publishConfig": {
"registry": "https://registry.npm.taobao.org/",
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/didi/DoraemonKit.git"
},
"bugs": {
"url": "https://github.com/didi/DoraemonKit/issues"
},
"scripts": {
"build": "env NODE_ENV=production npx ../../node_modules/.bin/rollup -c",
"dev": "npx ../../node_modules/.bin/rollup -wc"
},
"dependencies": {
"vue": "^3.0.11"
}
}
......@@ -4,9 +4,16 @@ import resolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import replace from 'rollup-plugin-replace'
import {terser} from 'rollup-plugin-terser'
const env = process.env.NODE_ENV
const extendPlugins = []
if(process.env.NODE_ENV === 'production'){
extendPlugins.push(terser())
}
export default {
input: 'src/main.js',
input: 'src/index.js',
output: {
name: 'dokit.js',
file: 'dist/dokit.js',
......@@ -22,6 +29,7 @@ export default {
}),
postcssPlugin(),
resolve({ extensions: ['.vue'] }),
commonjs()
commonjs(),
...extendPlugins
]
}
\ No newline at end of file
......@@ -38,12 +38,12 @@ export default {
font-family: Helvetica Neue,Helvetica,Arial,sans-serif;
}
.dokit-entry-btn{
width: 40px;
height: 40px;
width: 50px;
height: 50px;
padding: 10px;
box-sizing: border-box;
background-image: url(//pt-starimg.didistatic.com/static/starimg/img/ROnqquDh5u1574241122152.png);
background-size: 30px;
background-image: url(//pt-starimg.didistatic.com/static/starimg/img/OzaetKDzHr1618905183992.png);
background-size: 50px;
background-position: center;
background-repeat: no-repeat;
}
......
// dokit 外部插件示例
export default {
name: 'hello-plugin',
install(Vue) {
const { defineComponent, h } = Vue
return defineComponent({
name: 'ToolHelloPlugin',
componentName: 'ToolHelloPlugin',
setup() {
return () => h('div', ['~hello plugin~', 'this is a external plugin'])
}
})
}
}
......@@ -10,7 +10,7 @@
<body>
</body>
<script src="../dist/dokit.js"></script>
<script src="../packages/web/dist/dokit.js"></script>
<script>
dokit.init()
</script>
......
/**
* build 脚本
*/
const execa = require('execa')
run()
async function run(){
await build()
}
async function build(){
execa(
'rollup',
[
'-c'
],
{
stdio: 'inherit'
}
)
}
\ No newline at end of file
const http = require('http');
const serveHandler = require('serve-handler');
const open = require('open');
run();
function run(){
const server = http.createServer((request, response) => {
return serveHandler(request, response);
})
server.listen(3000, () => {
console.log('Dev Server Running at http://localhost:3000');
open('http://localhost:3000/playground');
})
}
const execa = require('execa');
const handler = require('serve-handler');
const http = require('http');
const open = require('open');
run()
async function run() {
startDev();
startServer();
open('http://localhost:3000/playground');
}
async function startDev() {
execa(
'rollup',
[
'-c',
'-w'
],
{
stdio: 'inherit'
}
)
}
async function startServer() {
const server = http.createServer((request, response) => {
// You pass two more arguments for config and middleware
// More details here: https://github.com/vercel/serve-handler#options
return handler(request, response, {
public: "./",
rewrites: [
{ "source": "/index.html", "destination": "./__tests__/fixture" },
]
});
})
server.listen(3000, () => {
console.log('Running at http://localhost:3000');
});
}
// TODO 待补充
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册