@serverless-devs/nodejs-deploy-best-practice
v0.0.5
Published
nodejs部署到fc函数计算最佳实践
Downloads
6
Readme
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 }
);
},
},
]
);
}
}