0.0.6 • Published 3 years ago

bam-auto-tool v0.0.6

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

BAM AUTO TOOL

本工具協助專案運行,產生各種專案所需的相應檔案。

使用方式

  1. 在 root 建立 tool.config.js
  2. 對應的工具建立對應的物件名稱,將其 config 寫入。
  3. package.jsonscripts 加入指令執行 node tool.config.js
require('bam-auto-tool')({
  index: {},
  svg: {},
  model: {},
})
package.json
{
  "scripts": {
    "tool": "node tool.config.js"
  }
}

Create Index

該工具用來建立資料夾的索引檔,可以選擇使用 ESM 或是 CJS,預設採用 ESM 模式。

設定建立範例

// tool.config.js
const indexConfig = {
  input: [
    'folder/filenA',
    {
      path: 'filenB',
      fileNameHandler: filename => {
        return rename(filename)
      },
    },
  ],
  output: {
    type: 'cjs',
  },
}

input API

nametypedefaultdescription
inputObject , Array , Stringundefinedinput path or input setting.
outputObject , Array , Stringundefinedoutput setting.
pathString`${root}`if input not string, index folder folder.
typeString'esm'file type,support cjs & esm.
prefixString''file ouput name, prefix text.
suffixString''file ouput name, suffix text.
filenameStringindex.jsindex file name.
fileNameHandlerFunction(f) => ConverBigHump(f)file ouput name,fix rule.

規則

  • 當 input、output 的設定衝突時,以 input 的設定優先。
  • path 會自動加上 root,以 cmd 指令的位置為準。
  • filename 只能在 output 使用

指令

$ npm run tool index