{"id":43543375,"url":"https://github.com/devsapp/website-fc","last_synced_at":"2026-02-03T18:38:15.768Z","repository":{"id":42506740,"uuid":"473162824","full_name":"devsapp/website-fc","owner":"devsapp","description":"Plugin for deploy a static website with fc","archived":false,"fork":false,"pushed_at":"2024-01-24T05:07:55.000Z","size":600,"stargazers_count":0,"open_issues_count":3,"forks_count":1,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-01-24T06:26:46.445Z","etag":null,"topics":["aliyun","fc","frontend","serverless","serverless-devs","website"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devsapp.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-23T11:43:40.000Z","updated_at":"2024-01-24T06:26:46.445Z","dependencies_parsed_at":"2022-09-08T20:11:41.401Z","dependency_job_id":null,"html_url":"https://github.com/devsapp/website-fc","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/devsapp/website-fc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsapp%2Fwebsite-fc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsapp%2Fwebsite-fc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsapp%2Fwebsite-fc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsapp%2Fwebsite-fc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devsapp","download_url":"https://codeload.github.com/devsapp/website-fc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devsapp%2Fwebsite-fc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29052650,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T15:43:47.601Z","status":"ssl_error","status_checked_at":"2026-02-03T15:43:46.709Z","response_time":96,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aliyun","fc","frontend","serverless","serverless-devs","website"],"created_at":"2026-02-03T18:38:10.155Z","updated_at":"2026-02-03T18:38:15.754Z","avatar_url":"https://github.com/devsapp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Website-fc Plugin\n![image](https://img.alicdn.com/imgextra/i1/O1CN01X9ucax1hNPxyaFLkb_!!6000000004265-2-tps-1810-686.png)\n\u003cp align=\"center\" class=\"flex justify-center\"\u003e\n  \u003ca href=\"https://nodejs.org/en/\" class=\"ml-1\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/node-%3E%3D%2010.8.0-brightgreen\" alt=\"node.js version\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/devsapp/website-fc/blob/master/LICENSE\" class=\"ml-1\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-MIT-green\" alt=\"license\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n本插件帮助您通过[Serverless-Devs](https://github.com/Serverless-Devs/Serverless-Devs)工具和[FC组件](https://github.com/devsapp/fc)，快速部署静态网站到阿里云函数计算平台。\n\n\n- [快速开始](#快速开始)\n  - [插件作用](#插件作用)\n  - [使用教程](#使用教程)\n    - [快速上手](#快速上手)\n    - [参数说明](#参数说明)\n    - [作用域](#作用域)\n  - [操作案例](#操作案例)\n  - [最佳实践](#最佳实践)\n  - [工作原理](#工作原理)\n- [关于我们](#关于我们)\n\n## 快速开始\n- [源码](https://github.com/devsapp/start-website/tree/master/vuepress/src)\n- 快速体验: `s init website-vuepress`\n### 插件作用\n#### 通过CDN+OSS部署\n通过[OSS组件](https://github.com/devsapp/oss)可以将静态资源快速部署到阿里云对象存储上，同时分发到CDN节点。不同地域的客户都能快速的访问对应的资源。\n\n![Images](https://img.alicdn.com/imgextra/i4/O1CN01yajAOr1qZd4TVVwCk_!!6000000005510-2-tps-928-468.png)\n\n\n上面的架构是比较推荐的最佳实践，能够保证高可用，和极致弹性，也是一个标准的Serverless架构。同时用户也能快速的访问它就近的资源，提供了最好的用户体验。\n\n#### 通过函数计算FC部署\n通过CDN+OSS的方式虽然在性能和弹性都做到了最优，但是有下面几种场景，用户会选择他的应用部署在函数计算上\n\n- 不希望太复杂的架构，前后端都部署在函数计算上\n- FullStack的框架，前后端都是一体化，前端部署在OSS有跨域的问题。如果要解决跨域的问题，又需要引入网关等组件，进一步带来了架构的复杂度\n- FaaS厂商一般都有免费额度，我的流量不高，部署在Faas足够用了\n\n![picture](https://img.alicdn.com/imgextra/i2/O1CN01mZSY8t1afYL39b670_!!6000000003357-2-tps-838-492.png)\n\n### 使用教程\n#### 快速上手\n`website-fc`本质是针对[FC组件](https://serverless-devs.com/fc/readme)进行增强。\n还是遵循FC组件的[Yaml规范](https://serverless-devs.com/fc/yaml/readme)，区别在于\n1. 在执行部署之前声明对应的插件`website-fc`\n```\nactions: # 自定义执行逻辑\n  pre-deploy: # 在deploy之前运行\n    - plugin: website-fc\n```\n2. 更改函数的[codeUri](https://serverless-devs.com/fc/yaml/function)为静态资源的本地地址\n```\nservices:\n  website:\n    component: fc\n    actions: # 自定义执行逻辑\n      pre-deploy: # 在deploy之前运行\n        - plugin: website-fc\n    props: #  组件的属性值\n      region: ${vars.region}\n      service: ${vars.service}\n      function:\n        name: http-trigger-nodejs14\n        description: 'hello world by serverless devs'\n        runtime: nodejs14\n        codeUri: ./build # 本地静态资源的地址\n```\n#### 参数说明\n\n参数详情：\n\n| 参数名称 | 默认值 | 参数含义 | 必填 |\n| --- | --- | --- |--- |\n| index  | index.html |  自定义默认首页    | false |\n\n\n我们知道访问静态网站需要一个`html`的页面作为首页，比如您访问`http://www.serverless-devs.com/`首页的时候，其实实际访问的资源是`http://www.serverless-devs.com/index.html`。\n\n`website-fc`插件的默认行为也是会将您的默认首页指向`index.html`。如果您需要自定义您的首页为`demo.html`。只需要做如下声明\n```\nactions: # 自定义执行逻辑\n  pre-deploy: # 在deploy之前运行\n    - plugin: website-fc\n      args:\n        index: demo.html\n```\n\n可以参考[案例](https://github.com/devsapp/start-realwrold/tree/master/src)\n\n#### 作用域\n`Website-fc`只能在`pre-deploy`阶段生效。\n```\nactions: # 自定义执行逻辑\n  pre-deploy: # 在deploy之前运行\n    - plugin: website-fc\n```\n\n### 操作案例\n- 项目目录结构\n```\n- dist\n  - index.htm\n- s.yaml\n```\n- yaml配置如下\n```\nedition: 1.0.0        #  命令行YAML规范版本，遵循语义化版本（Semantic Versioning）规范\nname: component-test   #  项目名称\naccess: default # 密钥别名\n\nvars: # 全局变量\n  region: cn-hangzhou\n  service:\n    name: hello-world-service\n    description: 'hello world by serverless devs'\n\nservices:\n  website:\n    component: fc\n    actions: # 自定义执行逻辑\n      pre-deploy: # 在deploy之前运行\n        - plugin: website-fc\n    props: #  组件的属性值\n      region: ${vars.region}\n      service: ${vars.service}\n      function:\n        name: http-trigger-nodejs14\n        description: 'hello world by serverless devs'\n        runtime: nodejs14   # 任何一个 runtime 都可以\n        codeUri: ./dist\n        memorySize: 128\n        timeout: 60\n      triggers:\n        - name: httpTrigger\n          type: http\n          config:\n            authType: anonymous\n            methods:\n              - GET\n      customDomains:\n        - domainName: auto\n          protocol: HTTP\n          routeConfigs:\n            - path: /*\n              methods:\n                - GET\n```\n\n### 最佳实践\n\n以下是来自社区实践后总结出的最佳实践:\n+ [如何使用 website-fc 插件部署静态网站到函数计算](https://blog.dengchao.fun/2022/04/02/deploy-static-website-with-website-fc-plugin/) by [DevDengChao](https://github.com/DevDengChao)\n\n欢迎大家通过 PR 投稿更多内容.\n\n### 工作原理\n#### 插件运行原理\n![image](https://img.alicdn.com/imgextra/i4/O1CN017Zfcf11XmvsJGfMeg_!!6000000002967-2-tps-1462-468.png)\n插件本质是上对[组件能力](https://www.serverless-devs.com/fc/readme)的增强，作用在组件的执行前(pre-deploy)以及执行后(post-deploy)。通过修改组件的入参(input)和出参(output)，提供能力。\n\u003e 需要注意的是：上一个插件的出参(output)会作为下一个插件或者组件的入参。详情可查看\n[插件模型开发指南](https://www.serverless-devs.com/sdm/serverless_package_model/package_model#%E6%8F%92%E4%BB%B6%E6%A8%A1%E5%9E%8B%E8%A7%84%E8%8C%83)\n\n\nwebsite-fc 插件在把你的代码部署到云端前将 `runtime` 覆盖为了 `custom` 运行时, 将 `caPort` 覆盖为了 `9000`,\n以及生成了[一段简单的监听 9000 端口的 Express 代码](https://github.com/devsapp/website-fc/blob/master/src/template.js)到最终的 codeUri 中, [并通过 `node` 启动了 Express HTTP 服务器](https://github.com/devsapp/website-fc/blob/master/src/index.js).\n\n# 关于我们\n- Serverless Devs 工具：\n    - 仓库：[https://www.github.com/serverless-devs/serverless-devs](https://www.github.com/serverless-devs/serverless-devs)    \n      \u003e 欢迎帮我们增加一个 :star2: \n    - 官网：[https://www.serverless-devs.com/](https://www.serverless-devs.com/)\n- 阿里云函数计算组件：\n    - 仓库：[https://github.com/devsapp/fc](https://github.com/devsapp/fc)\n    - 帮助文档：[https://www.serverless-devs.com/fc/readme](https://www.serverless-devs.com/fc/readme)\n- 钉钉交流群：33947367    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsapp%2Fwebsite-fc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevsapp%2Fwebsite-fc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevsapp%2Fwebsite-fc/lists"}