-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a3ef3da
commit 9d0b35b
Showing
31 changed files
with
552 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,3 @@ | ||
# 计划 | ||
Be-cli | ||
1.支持vue3 + vite模板 | ||
2.支持react + vite模板 | ||
3.纯ts库开发模板 | ||
|
||
## v1.0.0 | ||
### vue3 + vite + ts模板 | ||
|
||
## v1.2.0 | ||
### 纯ts库开发模板 | ||
|
||
## v1.3.0 | ||
gulp + rollup | ||
集成hasky、commitlint 🐶 | ||
集成eslint与格式修复 🐶 | ||
支持热更新开发调试 | ||
自定打包义脚本, | ||
支持打包类型生成、 | ||
支持产物压缩 | ||
支持多种格式cjs、esm | ||
支持总包、分包(分包时替换路径) | ||
支持指令参数修改环境变量 | ||
选择脚本是运行在 | ||
浏览器还是 | ||
node | ||
单测集成 | ||
vite | ||
jest | ||
|
||
选择模板 | ||
gulp + rollup | ||
tsup + gulp 🐶 | ||
|
||
|
||
## v1.x.x | ||
react + vite 模板 | ||
unbuild 模板 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "@baiwusanyu", | ||
"rules": { | ||
"no-console": ["warn", { "allow": ["log"] }] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/extensions.json | ||
!project/.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? | ||
auto-imports.d.ts | ||
components.d.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
|
||
npx --no -- commitlint --edit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm exec lint-staged --allow-empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import babel from '@rollup/plugin-babel' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import typescript from 'rollup-plugin-typescript2' | ||
import cleanup from 'rollup-plugin-cleanup' | ||
import { terser } from 'rollup-plugin-terser' | ||
import dts from 'rollup-plugin-dts' | ||
import { parallel } from 'gulp' | ||
import replace from 'rollup-plugin-replace' | ||
import { build } from './utils' | ||
|
||
const config = { | ||
input: '../packages/entry/index.ts', // 必须,入口文件 | ||
external: ['chalk'], | ||
plugins: [ | ||
// 引入的插件在这里配置 | ||
resolve(), | ||
typescript(), | ||
replace({ | ||
'process.env.CURRENT_ENV': '`web`', | ||
}), | ||
babel({ | ||
presets: ['@babel/preset-env'], | ||
exclude: '**/node_modules/**', | ||
babelHelpers: 'runtime', | ||
}), | ||
commonjs(), | ||
cleanup({ comments: 'none' }), | ||
terser(), | ||
], | ||
} | ||
|
||
const buildConfig = [ | ||
{ | ||
file: '../dist/index.js', | ||
format: 'es', | ||
inlineDynamicImports: true, | ||
name: 'index', | ||
}, | ||
{ | ||
file: '../dist/index.cjs', | ||
format: 'cjs', | ||
inlineDynamicImports: true, | ||
name: 'index', | ||
}, | ||
] | ||
|
||
const typeConfig = { | ||
input: '../packages/entry/index.ts', // 必须,入口文件 | ||
plugins: [ | ||
resolve(), | ||
typescript(), | ||
dts(), | ||
], | ||
} | ||
const buildTypeConfig = [ | ||
{ | ||
file: '../dist/index.d.ts', | ||
format: 'es', | ||
}, | ||
] | ||
|
||
// 打包处理 | ||
export const buildPackages = () => { | ||
return parallel(() => build(config, buildConfig), () => build(typeConfig, buildTypeConfig)) | ||
} | ||
export default buildPackages() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import resolve from '@rollup/plugin-node-resolve' | ||
import babel from '@rollup/plugin-babel' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import typescript from 'rollup-plugin-typescript2' | ||
import cleanup from 'rollup-plugin-cleanup' | ||
import { terser } from 'rollup-plugin-terser' | ||
import dts from 'rollup-plugin-dts' | ||
import replace from 'rollup-plugin-replace' | ||
import { build } from './utils' | ||
import {OutputOptions} from "rollup"; | ||
|
||
const config = { | ||
input: '../packages/entry/index.ts', | ||
external: [ | ||
'chalk', | ||
'@template-node-rollup/utils', | ||
'@template-node-rollup/runtime' | ||
], | ||
output:[], | ||
plugins: [], | ||
} | ||
const plugins = [ | ||
// 引入的插件在这里配置 | ||
resolve(), | ||
typescript(), | ||
replace({ | ||
'process.env.CURRENT_ENV': '`web`', | ||
}), | ||
babel({ | ||
presets: ['@babel/preset-env'], | ||
exclude: '**/node_modules/**', | ||
babelHelpers: 'runtime', | ||
}), | ||
commonjs(), | ||
cleanup({ comments: 'none' }), | ||
terser(), | ||
] | ||
let entry = { | ||
index: {entry:'../packages/entry/index.ts',output:'../dist/index',}, | ||
runtime: {entry:'../packages/runtime/index.ts',output:'../dist/runtime/index',}, | ||
utils: {entry:'../utils/index.ts',output:'../dist/utils/index',}, | ||
} | ||
|
||
const typeConfig = { | ||
input: '../packages/entry/index.ts', // 必须,入口文件 | ||
plugins: [], | ||
} | ||
|
||
const typePlugins = [ | ||
resolve(), | ||
typescript(), | ||
dts(), | ||
] | ||
const createBuildOption = (config,plugins,isType?:boolean) =>{ | ||
let option = [] | ||
let len = 0 | ||
for (const entryKey in entry) { | ||
let inputConfig = JSON.parse(JSON.stringify(config)) | ||
inputConfig.input = entry[entryKey].entry | ||
inputConfig.plugins = plugins | ||
let outputConfig = [] | ||
if(isType){ | ||
outputConfig = [ | ||
{ | ||
file: `${entry[entryKey].output}.d.ts`, | ||
format: 'es', | ||
}, | ||
] | ||
}else{ | ||
outputConfig = [ | ||
{ | ||
file: `${entry[entryKey].output}.js`, | ||
format: 'es', | ||
inlineDynamicImports: true, | ||
name: 'index', | ||
}, | ||
{ | ||
file: `${entry[entryKey].output}.cjs`, | ||
format: 'cjs', | ||
inlineDynamicImports: true, | ||
name: 'index', | ||
} | ||
] as OutputOptions[] | ||
} | ||
option.push(async () => await build(inputConfig, outputConfig)) | ||
len++ | ||
} | ||
return option | ||
} | ||
|
||
|
||
|
||
// 打包处理 | ||
const buildPackages = () => { | ||
const buildList = createBuildOption(config,plugins) | ||
const buildTypeList = createBuildOption(typeConfig,typePlugins,true) | ||
return [...buildList,...buildTypeList] | ||
} | ||
export default buildPackages() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { series } from 'gulp' | ||
import { rewritePath } from './rewirte-path' | ||
import buildAllPackages from './build-all' | ||
import buildSplitPackages from './build-Split' | ||
|
||
const buildMode = process.env.BUILD_MODE | ||
|
||
let taskList = [] | ||
if (buildMode === 'all') { | ||
taskList = [ | ||
buildAllPackages, | ||
] | ||
} | ||
|
||
if (buildMode === 'split') { | ||
taskList = [ | ||
...buildSplitPackages, | ||
...rewritePath(), | ||
] | ||
} | ||
|
||
export default series(...taskList) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"name": "@template-node-rollup/build", | ||
"type": "module", | ||
"version": "1.0.0", | ||
"description": "", | ||
"author": "", | ||
"license": "ISC", | ||
"keywords": [], | ||
"scripts": { | ||
"build:split": "cross-env BUILD_MODE=split gulp -require sucrase/register/ts -f gulp-file.ts", | ||
"build:all": "cross-env BUILD_MODE=all gulp -require sucrase/register/ts -f gulp-file.ts" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.19.0", | ||
"@babel/preset-env": "^7.19.0", | ||
"@babel/preset-typescript": "^7.16.0", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
"@rollup/plugin-commonjs": "^22.0.2", | ||
"@rollup/plugin-node-resolve": "^14.1.0", | ||
"@template-node-rollup/entry": "*", | ||
"cross-env": "^7.0.3", | ||
"esno": "^0.16.3", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.79.0", | ||
"rollup-plugin-cleanup": "^3.2.1", | ||
"rollup-plugin-dts": "^4.2.1", | ||
"rollup-plugin-replace": "^2.2.0", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"rollup-plugin-typescript2": "^0.34.0", | ||
"sucrase": "^3.21.0", | ||
"typescript": "4.7.4" | ||
} | ||
} |
Oops, something went wrong.