npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@boxcc/next-hsuc

v0.0.8

Published

react服务端渲染,打包文件上传到云端,提高加载速度

Downloads

2

Readme

语言

中文

describe

Upload the files generated by web pack to the cloud to improve the loading speed
Currently, Alibaba cloud, Huawei cloud, Tencent cloud, qiniu cloud and remake cloud, as well as user-defined extensions are supported.

install

npm install next-hsuc --save-dev

required

Node

Node.js >= 10.10.0

use

package.json add script

// cross-env needs to be installed first, npm install cross-env --save-dev

"dev": "cross-env PORT=80 PROXY=true node server.js",
"build": "cross-env NODE_ENV=production next build",
"start": "cross-env NODE_ENV=production PORT=80 PROXY=true node server.js"

server.js You can use your own. This is just an example

const express = require(`express`);
const next = require(`next`);
const { NODE_ENV, PORT=3000, PROXY } = process.env;
const app = next({dir: `.`, dev: NODE_ENV !== "production"});

app.prepare()
  .then(() => {
    const server = express();

    server.listen(PORT, (err) => {
      if (err) {
        throw err
      }
      console.log(`> Ready on port ${PORT} [${NODE_ENV}]`);
    })
  })
  .catch((ex) => {
    console.log(`An error occurred, unable to start the server`)
    console.log(ex)
  });

next.config.js

// webpack.config.js
const withPlugins = require ("next-compose-plugins");
const {PHASE_DEVELOPMENT_SERVER} = require(`next-server/constants`);
const Hsuc = require(`hsuc`);
const HsucOptions = {
    cloudFolder: "<Cloud folder>",
    domain: "<domain name>",
    enable: true,
    // Alicloud (Choose one)
    aliyun: {
      region: "<OSS region>",
      accessKeyId: "<Your accessKeyId>",
      accessKeySecret: "<Your accessKeySecret>",
      bucket: "<Your bucket name>"
    }
    // Hua Weiyun (Choose one)
    huawei: {
      accessKeyId: "<Provide your Access Key>",
      secretAccessKey: "<Provide your Secret Key>",
      server: "<https://your-endpoint>",
      bucket: "<Bucket>"
    },
    // Tencent cloud (Choose one)
    tencent: {
      secretId: "<SecretId>",
      secretKey: "<SecretKey>",
      bucket: "<Bucket>",
      region: "<Region>"
    },
    // Qiniu cloud (Choose one)
    qiniu: {
      accessKey: "<ACCESS_KEY>",
      secretKey: "<SECRET_KEY>",
      bucket: "<Bucket>"
    },
    // Clapping clouds again (Choose one)
    upyun: {
      serviceName: "<service name>",
      operatorName: "<operator name>",
      operatorPassword: "<operator password>",
    }
}

const nextConfig = {
  webpack: (config, options) => {
    config.plugins.push(
      new Hsuc(Object.assign(HsucOptions, options))
    )

    return config;
  },
  distDir: "_next",
  ["!" + (HsucOptions.enable ? PHASE_DEVELOPMENT_SERVER : "")]: {
    assetPrefix: `${HsucOptions.domain}/${HsucOptions.cloudFolder}`,
  }
};

module.exports = withPlugins(
    [...], 
    nextConfig);
)

hsuc(options) supported options

  • aliyun - Initialize alicloud OSS parameters
  • huawei - Initialize Huawei cloud OBS parameters.
  • tencent - Initialize Tencent cloud cos parameters.
  • qiniu - Initialize the Qiniu cloud parameter.
  • upyun - Initialize the re shooting cloud parameter.
  • enable[boolean] - Enable at the beginning, defaulttrue
  • removePrevVersion[boolean] - Delete previous versions of cloud or not, defaultfalse
  • log[boolean] - Display log, defaulttrue
  • cover[boolean|RegExp] - Overwrite file, defaultfalse. Please refer to/\.(png|jpe?g|gif|ico|woff2?|svg|ttf|eot)$/
  • custom[js文件,例如require("./template.js")] - User defined upload file, you can refer to the template.js in the project

Object store CORS rule settings

  • aliyun Set according to CORS
  • huawei Set according to CORS
  • tencent Set according to CORS
  • qiniu Set according to CORS
  • upyun Set according to CORS

matters needing attention

  • Please set the cloud access to "public read / write" or "public read"
  • In the options parameter, aliyun, huawei, tencent, qiniu and upyun are configured at the same time, only the first one is valid
  • The plug-in is disabled in development mode
  • options.deletePrevBuildFile Enabling this item will delete the previous version. Please be careful.

deploy

npm run build
mpm run start