Skip to content

Commit 86e6462

Browse files
committed
init
0 parents  commit 86e6462

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+28075
-0
lines changed

.browserslistrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
> 1%
2+
last 2 versions

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root = true
2+
3+
[*]
4+
charset=utf-8
5+
end_of_line=lf
6+
insert_final_newline=false
7+
indent_style=space
8+
indent_size=2
9+
10+
[{.eslintrc,.babelrc,.stylelintrc,*.json}]
11+
indent_style=space
12+
indent_size=2
13+
14+
[*.less]
15+
indent_style=space
16+
indent_size=2
17+
18+
[*.{js,jsx,ts,tsx,vue,html}]
19+
indent_style=space
20+
indent_size=2

.eslintignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
*.sh
3+
node_modules
4+
lib
5+
*.md
6+
*.scss
7+
*.woff
8+
*.ttf
9+
.vscode
10+
.idea
11+
./vue.config.js
12+
/build/
13+
/dist/
14+
/public/
15+
/script/
16+
/config/
17+
/docs
18+
.vscode

.eslintrc.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true
5+
},
6+
extends: ['plugin:vue/recommended', '@vue/standard'],
7+
rules: {
8+
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
9+
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
10+
'space-before-function-paren': 'off',
11+
// 禁止在计算属性中对属性修改
12+
'vue/no-side-effects-in-computed-properties': 'off',
13+
// 属性空格
14+
'vue/attribute-hyphenation': 'off'
15+
},
16+
parserOptions: {
17+
parser: 'babel-eslint'
18+
},
19+
overrides: [
20+
{
21+
files: ['**/__tests__/*.{j,t}s?(x)'],
22+
env: {
23+
jest: true
24+
}
25+
}
26+
]
27+
}

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
5+
/tests/e2e/videos/
6+
/tests/e2e/screenshots/
7+
8+
# local env files
9+
.env.local
10+
.env.*.local
11+
12+
# Log files
13+
npm-debug.log*
14+
yarn-debug.log*
15+
yarn-error.log*
16+
17+
# Editor directories and files
18+
.idea
19+
.vscode
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

.npmignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
build
2+
example
3+
docs
4+
babel.config.js
5+
.prettierignore
6+
prettier.config.js
7+
postcss.config.js
8+
.eslintrc.js
9+
.travis.yml
10+
.eslintrc.js
11+
.eslintignore
12+
yarn.lock
13+
jest.config.js
14+
cypress.json
15+
node_modules
16+
.browserslistrc
17+
yarn-error.log
18+
npm-debug.log
19+
dist
20+
test

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/docs/*
2+
/lib/*

.stylelintignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
*.js
2+
*.png
3+
*.eot
4+
*.ttf
5+
*.woff
6+
7+
/dist/
8+
/lib/
9+
/public/
10+
.output.js

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# vue-lib-starter
2+
3+
[文档地址](https://juejin.im/post/5d7860b0f265da03bc12a3d2)
4+
5+
6+
## 安装依赖
7+
```
8+
yarn install
9+
```
10+
11+
### 运行example
12+
```
13+
yarn run serve
14+
```
15+
16+
17+
### 运行测试用例
18+
```
19+
yarn run test:unit
20+
```
21+
22+
### 使用vue-cli3 打包库
23+
```
24+
yarn run lib:cli
25+
```
26+
27+
### 使用rollup打包库
28+
```
29+
yarn run lib
30+
```
31+
32+
### 格式化全部js文件
33+
```
34+
yarn run lint:prettier
35+
```
36+
37+
### 格式化全部css文件
38+
```
39+
yarn run lint:css
40+
```
41+
### 运行项目文档
42+
```
43+
yarn run docs:dev
44+
```
45+
46+
### 打包项目文档
47+
```
48+
yarn run docs:build
49+
```
50+
51+
### 生成修改日志
52+
```
53+
yarn run version
54+
```

babel.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var { clearConsole } = require('./config/index')
2+
3+
var plugins = [
4+
[
5+
'import',
6+
{
7+
libraryName: 'vue-drag-tree',
8+
style: (name, file) => {
9+
const libDirIndex = name.lastIndexOf('/')
10+
const libDir = name.substring(0, libDirIndex)
11+
const fileName = name.substring(libDirIndex + 1)
12+
return `${libDir}/theme/${fileName}.css`
13+
}
14+
}
15+
]
16+
]
17+
clearConsole && plugins.push('transform-remove-console')
18+
module.exports = {
19+
presets: ['@babel/preset-env'],
20+
21+
plugins: plugins
22+
}

build/cli.build.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
const { run } = require('runjs')
2+
const libList = require('../src/lib-list.js')
3+
const { addons } = require('../config/rollup.build.config.js')
4+
const { getAssetsPath, chalkConsole, resolve, fsExistsSync } = require('./utils')
5+
const { styleOutputPath } = require('../config/index')
6+
const { move, fileDisplay } = require('../script/file-handle')
7+
const rimraf = require('rimraf')
8+
const fs = require('fs')
9+
const cssFiles = []
10+
11+
function build({ input, output } = {}, index, arr) {
12+
chalkConsole.building(index + 1, arr.length)
13+
run(
14+
`vue-cli-service build --target lib --no-clean --name ${output} --dest ${getAssetsPath()} ${input}`
15+
)
16+
cssFiles.push(`${output}.css`)
17+
}
18+
19+
let pkg = []
20+
21+
Object.keys(libList).forEach((moduleName) => {
22+
const { input, output } = libList[moduleName]
23+
pkg.push({ input, output })
24+
})
25+
pkg = pkg.concat(addons)
26+
pkg.forEach(build)
27+
// 删除多余文件
28+
rimraf(getAssetsPath('./demo.html'), function() {})
29+
// 创建样式文件夹
30+
fs.mkdirSync(getAssetsPath(styleOutputPath))
31+
// 拷贝css文件到单独目录
32+
cssFiles.forEach((cssFile) => {
33+
fsExistsSync(getAssetsPath(cssFile)) &&
34+
move(getAssetsPath(cssFile), getAssetsPath(styleOutputPath + '/' + cssFile))
35+
})
36+
// 重命名common文件
37+
fileDisplay(getAssetsPath(), (file) => {
38+
const reg = /.common/
39+
if (reg.test(file)) {
40+
file = `../${file}`
41+
move(resolve(file), resolve(file.replace(reg, '')))
42+
}
43+
})
44+
45+
chalkConsole.success()

build/rollup.build.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const fs = require('fs')
2+
const { formatTypeList, addons, esDir } = require('../config/rollup.build.config.js')
3+
const libList = require('../src/lib-list.js')
4+
const { styleOutputPath } = require('../config/index')
5+
const { build } = require('./rollup.createConfig')
6+
const { resolve, getAssetsPath } = require('./utils')
7+
fs.mkdirSync(resolve())
8+
fs.mkdirSync(getAssetsPath(styleOutputPath))
9+
if ([...formatTypeList, ...addons].some((item) => item.format === esDir)) {
10+
fs.mkdirSync(getAssetsPath(esDir))
11+
}
12+
let pkg = []
13+
formatTypeList.forEach(({ format, min, suffix } = {}) => {
14+
Object.keys(libList).forEach((moduleName) => {
15+
const { input, output } = libList[moduleName]
16+
pkg.push({ min, format, suffix, moduleName, input, output: `${output}` })
17+
})
18+
})
19+
pkg = pkg.concat(addons)
20+
21+
build(pkg)
22+
// pkg.forEach(build)

0 commit comments

Comments
 (0)