Skip to content

Commit

Permalink
feat: 新增行内配置
Browse files Browse the repository at this point in the history
  • Loading branch information
ahwgs committed May 13, 2021
1 parent 6a24b84 commit 81bbcc5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
9 changes: 9 additions & 0 deletions examples/build-demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "build-demo",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build": "../../packages/cli/bin/avenger.js build"
}
}
Empty file.
7 changes: 5 additions & 2 deletions packages/cli/src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: ahwgs
* @Date: 2021-04-02 00:22:55
* @Last Modified by: ahwgs
* @Last Modified time: 2021-04-28 16:04:52
* @Last Modified time: 2021-05-13 15:57:15
*/

import path from 'path'
Expand All @@ -22,7 +22,10 @@ export const registerCommand = () => {
.description('打包')
.option('--file', '打包输出文件名')
.option('--entry', '打包主入口')
.option('-w, --watch', 'watch 模式')
.option('--watch', 'watch 模式')
.option('--esm', '打包esm')
.option('--cjs', '打包cjs')
.option('--umd', '打包umd')

.allowUnknownOption()
.action(() => build(getBuildArguments()))
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author: ahwgs
* @Date: 2021-04-01 00:06:20
* @Last Modified by: ahwgs
* @Last Modified time: 2021-04-27 22:50:06
* @Last Modified time: 2021-05-13 15:58:16
*/
import { semver, error } from '@osdoc-dev/avenger-utils'
import minimist, { ParsedArgs } from 'minimist'
Expand All @@ -20,14 +20,17 @@ export const checkNodeVersion = (needVerison: string, packageName: string) => {

export const getBuildArguments = () => {
const opt = minimist(process.argv.slice(3))
const { file, entry, watch, w } = opt as ParsedArgs
const isWatch = !!watch || !!w
const { file, entry, watch, esm, cjs, umd } = opt as ParsedArgs
console.log('opt', opt)
return {
cwd: process.cwd(),
watch: isWatch,
watch: watch || false,
inlineConfig: {
outFile: file,
entry,
esm: esm ? 'rollup' : false,
cjs: cjs ? 'rollup' : false,
umd: umd ? 'rollup' : false,
},
} as ICliOpt
}
2 changes: 1 addition & 1 deletion packages/core/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: ahwgs
* @Date: 2021-04-02 09:45:43
* @Last Modified by: ahwgs
* @Last Modified time: 2021-05-07 23:21:08
* @Last Modified time: 2021-05-13 15:57:16
*/
import path from 'path'
import {
Expand Down

0 comments on commit 81bbcc5

Please sign in to comment.