@serverless-devs/nodejs-deploy-best-practice

0.0.5 • Public • Published

nodejs-deploy-best-practice

Serverless-Devs Nodejs组件开发最佳实践工具包,主要实现下面几个能力

  • 只安装部署dependencies的package,减少部署包体积。 npm install --prodution
  • rollup, esbuild,webpack 减少包体积,进而减少冷启动时间
  • 统一部署流程,Nodejs生态的部署组件交互行为保持一致

使用方法

const BestPractice = require("@serverless-devs/nodejs-deploy-best-practice");
class NuxtComponent extends BestPractice {
  constructor() {
    super();
  }
  async deploy(inputs) {
    return await super.deploy(
      inputs,
      (deployPath) => [
        {
          title: "Copy files to publish path",
          task: async () => {
            await fs.copy(
              path.join(__dirname, "template"),
              path.join(deployPath),
              {}
            );
            await fs.copy(
              path.join(currentPath, "static"),
              path.join(deployPath, "static")
            );
            await fs.copy(
              path.join(currentPath, "./nuxt.config.js"),
              path.join(deployPath, "./nuxt.config.js")
            );
          },
        },
      ],
      (deployPath) => [
        {
          title: "Run Nuxt build",
          task: async () => {
            await execa("npm", ["run", "build"]);
            await fs.move(
              path.join(currentPath, ".nuxt"),
              path.join(deployPath, ".nuxt"),
              { overwrite: true }
            );
          },
        },
      ]
    );
  }
}

Package Sidebar

Install

npm i @serverless-devs/nodejs-deploy-best-practice

Weekly Downloads

0

Version

0.0.5

License

ISC

Unpacked Size

20.4 kB

Total Files

12

Last publish

Collaborators

  • serverlessfans
  • heimanba
  • xsahxl