提交 8cea37ff 编写于 作者: D duanlikang

chore: update dokit/web script

上级 13aa13a3
## 开发
工程的开发规范以及开发模式
### 项目介绍
TODO
### 开发
#### Dev 开发
1. `npm install` 安装相关依赖
2. `npm run dev` 开启 Dev 服务
3. 浏览器访问 `http://localhost:3000/playground` 即可
#### Build
1. 执行 `npm run build`即可
### 发包
TODO
### 开发规范
#### 组件篇
##### 样式
- 所有的组件编写的时候,样式必须设定 scoped
......@@ -4,18 +4,13 @@
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<title>Dokit Web</title>
</head>
<body>
<div id="app"></div>
<script src="./dist/dokit.js"></script>
<script src="../../dist/dokit.js"></script>
<script>
dokit.init()
</script>
<script>
console.log('1');
console.log({a:1}, {b: {c:2}})
console.log([1, 2])
</script>
</body>
</html>
......@@ -5,20 +5,23 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rollup --config rollup.config.js",
"dev": "rollup -w --config rollup.config.js"
"build": "node scripts/build.js",
"dev": "node scripts/dev.js"
},
"author": "caoenze",
"license": "ISC",
"devDependencies": {
"@vue/compiler-sfc": "^3.0.7",
"execa": "^5.0.0",
"less": "^4.1.1",
"open": "^8.0.6",
"rollup": "^2.41.1",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-postcss": "^4.0.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-vue": "^6.0.0-beta.10"
"rollup-plugin-vue": "^6.0.0-beta.10",
"serve-handler": "^6.1.3"
},
"dependencies": {
"vue": "^3.0.7"
......
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<title>Dokit For Web</title>
</head>
<body>
</body>
<script src="../dist/dokit.js"></script>
<script type="module">
import helloPlugin from './HelloPlugin.js'
dokit.registerPlugin(helloPlugin).init()
</script>
<script type="module">
console.log('a', {a: {aaaa: 1, b:{a: 1}, c:1, d:1, e:1, f:1, g:1, h:1}})
<script>
dokit.init()
</script>
</html>
\ No newline at end of file
/**
* 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 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.
先完成此消息的编辑!
想要评论请 注册