{"id":25613479,"url":"https://github.com/kszitt/next-hsuc","last_synced_at":"2025-04-13T19:13:33.669Z","repository":{"id":57100595,"uuid":"256162768","full_name":"kszitt/next-hsuc","owner":"kszitt","description":"Render on the react server, package files and upload them to the cloud to improve the loading speed","archived":false,"fork":false,"pushed_at":"2020-04-22T07:46:27.000Z","size":25,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-27T09:52:12.794Z","etag":null,"topics":["aliyun-oss","cloud","huaweicloud","next","nextjs","obs","oss","qiniu","upyun","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kszitt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-16T09:01:52.000Z","updated_at":"2024-10-12T06:18:01.000Z","dependencies_parsed_at":"2022-08-20T21:40:30.639Z","dependency_job_id":null,"html_url":"https://github.com/kszitt/next-hsuc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-hsuc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-hsuc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-hsuc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kszitt%2Fnext-hsuc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kszitt","download_url":"https://codeload.github.com/kszitt/next-hsuc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248519540,"owners_count":21117761,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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-oss","cloud","huaweicloud","next","nextjs","obs","oss","qiniu","upyun","webpack"],"created_at":"2025-02-22T01:31:37.157Z","updated_at":"2025-04-13T19:13:33.646Z","avatar_url":"https://github.com/kszitt.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## 语言\n[中文](https://github.com/kszitt/next-hsuc/blob/master/README_ZH.md)\n\n## describe\nUpload the files generated by web pack to the cloud to improve the loading speed  \nCurrently, Alibaba cloud, Huawei cloud, Tencent cloud, qiniu cloud and remake cloud, as well as user-defined extensions are supported.\n\n## install\n```bash\nnpm install next-hsuc --save-dev\n```\n\n## required\n### Node\nNode.js \u003e= 10.10.0\n\n## use\n#### package.json add script\n```bash\n// cross-env needs to be installed first, npm install cross-env --save-dev\n\n\"dev\": \"cross-env PORT=80 PROXY=true node server.js\",\n\"build\": \"cross-env NODE_ENV=production next build\",\n\"start\": \"cross-env NODE_ENV=production PORT=80 PROXY=true node server.js\"\n```\n\n#### server.js You can use your own. This is just an example\n```bash\nconst express = require(`express`);\nconst next = require(`next`);\nconst { NODE_ENV, PORT=3000, PROXY } = process.env;\nconst app = next({dir: `.`, dev: NODE_ENV !== \"production\"});\n\napp.prepare()\n  .then(() =\u003e {\n    const server = express();\n\n    server.listen(PORT, (err) =\u003e {\n      if (err) {\n        throw err\n      }\n      console.log(`\u003e Ready on port ${PORT} [${NODE_ENV}]`);\n    })\n  })\n  .catch((ex) =\u003e {\n    console.log(`An error occurred, unable to start the server`)\n    console.log(ex)\n  });\n```\n\n#### next.config.js\n```bash\n// webpack.config.js\nconst withPlugins = require (\"next-compose-plugins\");\nconst {PHASE_DEVELOPMENT_SERVER} = require(`next-server/constants`);\nconst Hsuc = require(`hsuc`);\nconst HsucOptions = {\n    cloudFolder: \"\u003cCloud folder\u003e\",\n    domain: \"\u003cdomain name\u003e\",\n    enable: true,\n    // Alicloud (Choose one)\n    aliyun: {\n      region: \"\u003cOSS region\u003e\",\n      accessKeyId: \"\u003cYour accessKeyId\u003e\",\n      accessKeySecret: \"\u003cYour accessKeySecret\u003e\",\n      bucket: \"\u003cYour bucket name\u003e\"\n    }\n    // Hua Weiyun (Choose one)\n    huawei: {\n      accessKeyId: \"\u003cProvide your Access Key\u003e\",\n      secretAccessKey: \"\u003cProvide your Secret Key\u003e\",\n      server: \"\u003chttps://your-endpoint\u003e\",\n      bucket: \"\u003cBucket\u003e\"\n    },\n    // Tencent cloud (Choose one)\n    tencent: {\n      secretId: \"\u003cSecretId\u003e\",\n      secretKey: \"\u003cSecretKey\u003e\",\n      bucket: \"\u003cBucket\u003e\",\n      region: \"\u003cRegion\u003e\"\n    },\n    // Qiniu cloud (Choose one)\n    qiniu: {\n      accessKey: \"\u003cACCESS_KEY\u003e\",\n      secretKey: \"\u003cSECRET_KEY\u003e\",\n      bucket: \"\u003cBucket\u003e\"\n    },\n    // Clapping clouds again (Choose one)\n    upyun: {\n      serviceName: \"\u003cservice name\u003e\",\n      operatorName: \"\u003coperator name\u003e\",\n      operatorPassword: \"\u003coperator password\u003e\",\n    }\n}\n\nconst nextConfig = {\n  webpack: (config, options) =\u003e {\n    config.plugins.push(\n      new Hsuc(Object.assign(HsucOptions, options))\n    )\n\n    return config;\n  },\n  distDir: \"_next\",\n  [\"!\" + (HsucOptions.enable ? PHASE_DEVELOPMENT_SERVER : \"\")]: {\n    assetPrefix: `${HsucOptions.domain}/${HsucOptions.cloudFolder}`,\n  }\n};\n\nmodule.exports = withPlugins(\n    [...], \n    nextConfig);\n)\n```\n\n## hsuc(options) supported options\n- `aliyun` - Initialize alicloud OSS parameters\n- `huawei` - Initialize Huawei cloud OBS parameters.\n- `tencent` - Initialize Tencent cloud cos parameters.\n- `qiniu` - Initialize the Qiniu cloud parameter.\n- `upyun` - Initialize the re shooting cloud parameter.\n- `enable[boolean]` - Enable at the beginning, default`true`。\n- `removePrevVersion[boolean]` - Delete previous versions of cloud or not, default`false`\n- `log[boolean]` - Display log, default`true`\n- `cover[boolean|RegExp]` - Overwrite file, default`false`. Please refer to`/\\.(png|jpe?g|gif|ico|woff2?|svg|ttf|eot)$/`。\n- `custom[js文件，例如require(\"./template.js\")]` - User defined upload file, you can refer to the `template.js` in the project\n\n\n## Object store CORS rule settings\n- `aliyun` Set according to [CORS](https://help.aliyun.com/document_detail/44570.html?spm=5176.8465980.0.0.12871450vh6n2z)\n- `huawei` Set according to [CORS](https://support.huaweicloud.com/sdk-browserjs-devg-obs/obs_24_0201.html)\n- `tencent` Set according to [CORS](https://cloud.tencent.com/document/product/436/13318)\n- `qiniu` Set according to [CORS](https://console.upyun.com/services/kszitt/antileechFile/)\n- `upyun` Set according to [CORS](http://docs.upyun.com/cdn/feature/#cors)\n\n## matters needing attention\n- Please set the cloud access to \"public read / write\" or \"public read\"\n- In the options parameter, `aliyun`, `huawei`, `tencent`, `qiniu` and `upyun` are configured at the same time, only the first one is valid\n- The plug-in is disabled in development mode\n- `options.deletePrevBuildFile` Enabling this item will delete the previous version. Please be careful.\n\n## deploy\n``` hash\nnpm run build\nmpm run start\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkszitt%2Fnext-hsuc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkszitt%2Fnext-hsuc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkszitt%2Fnext-hsuc/lists"}