1 Star 1 Fork 0

白鸢 / after-build

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

@whitekite/after-build

提供自动部署,代码压缩,代码备份功能

🇨🇳国内用户可访问国内镜像

使用

import { createAfterBuild } from '@whitekite/after-build'

createAfterBuild({
  // 可选,可用于配置不同环境的不同部署服务器,
  // 默认:production
  mode: 'build-test',
  // 可选,借助 dotenv为配置文件提供环境变量
  env: process.env,
  // 开启本工具任何功能时,该选项都为必填
  outputPath: '/User/outputPath',
  // 可选 ,详见 AfterBuildFullConfig
  // 在未使用配置文件的情况下,提供默认设置
  config: {},
})

配置文件

  • 设置默认使用 afterBuild.config.[ext]
  • 可根据 设置的不同 mode 使用 afterBuild.[mode].[ext]

配置文件示例

// afterBuild.config.ts afterBuild.config.local.ts
import { defineConfig } from '@whitekite/after-build'

export default defineConfig({
  compress: 'gzip',
  /**
   * 打包文件备份功能,传递任意字符串开启该功能
   * 传递的字符串作为备份文件的前缀
   * 支持 Mustache 风格的参数解析
   * 支持的参数 {{name}} package.json 的name
   * 支持的参数 {{version}} package.json 的version
   * 支持的参数 {{mode}} 打包的模式
   * 支持的参数 {{time}} 打包时的时间
   * 示例(这也是传递true时的默认值):
   * {{name}}-{{mode}}-{{time}}
   */
  backup: 'folder-name-{{name}}-{{mode}}-{{time}}',
  publish: {
    enable: true,
    host: 'http://XXXX.XXXX.XXX',
    port: 30,
    user: 'root',
    password: 'pass',
    path: '/user/local/folder',
    /**
     * 代码压缩后上传至代码服务器
     * 用于应对大型项目文件数量多导致拖慢上传速度的问题
     * 该功能处于实验阶段,暂只支持linux服务器
     */
    zipUpload: true,
  },
})

export default defineConfig((env) => ({
  compress: 'gzip',
  /**
   * 打包文件备份功能,传递任意字符串开启该功能
   * 传递的字符串作为备份文件的前缀
   * 支持 Mustache 风格的参数解析
   * 支持的参数 {{name}} package.json 的name
   * 支持的参数 {{version}} package.json 的version
   * 支持的参数 {{mode}} 打包的模式
   * 支持的参数 {{time}} 打包时的时间
   * 示例(这也是传递true时的默认值):
   * {{name}}-{{mode}}-{{time}}
   */
  backup: 'folder-name-{{name}}-{{mode}}-{{time}}',
  publish: {
    enable: env.VITE_AUTO_PUBLISH,
    host: 'http://XXXX.XXXX.XXX',
    port: 30,
    user: 'root',
    password: 'pass',
    path: '/user/local/folder',
    /**
     * 代码压缩后上传至代码服务器
     * 用于应对大型项目文件数量多导致拖慢上传速度的问题
     * 该功能处于实验阶段,暂只支持linux服务器
     */
    zipUpload: true,
  },
}))

推送回滚

package.json

示例备份文件名称 projectName-test-20228022.zip

{
  "scripts": {
    "cli:rollback": "whitekite-after-build rollback --mode build-test --version projectName-test-20228022"
  }
}

命令行执行

package.json

{
  "scripts": {
    "cli:afterBuild": "whitekite-after-build run --mode build-test --compress.gzip --compress.br --backup web --outputPath /file-path"
  }
}
MIT License Copyright (c) 2022 白鸢 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

unplugin 赋能 同时兼容webpack与vite 运行于打包结束之后 提供自动部署,代码压缩,代码备份功能 展开 收起
TypeScript 等 4 种语言
MIT
取消

发行版 (15)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/white-kite/after-build.git
git@gitee.com:white-kite/after-build.git
white-kite
after-build
after-build
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891