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

deploy-nginx-xxjss

v1.0.9

Published

webpack项目 +centOS 7 + nginx 自动化部署

Downloads

4

Readme

webpack 的 dist 包 自动化部署 插件

本插件 是-只用 服务部署插件,
基于 centOS 7 + nginx  用于部署 webpack 生成的dist 包,
自动化部署到远程服务器,并实现自动重启nginx 服务

该插件 主要有三个 功能

    1.  初始化服务器 可以自动联网 安装 nginx 环境;
        可通过 nginx.conf 文件配置 远程服务器 nginx 的运行环境;

    2. 远程服务器,自动创建 环境依赖文件-所需存放文件夹、自动创建 项目所需文件夹;
    
    3.  build 项目 为dist 文件 并压缩 为 dist.zip 文件 并上传到 远程服务器 指定目录下  /data/www/dist.zip ;
        远程服务器 解压 dist.zip 文件 到 /data/www/dist 目录下;
        重启 nginx 服务;
        删除 远程服务器 指定目录下的30天以前的(自定义源码可改过期时间,默认30天) dist.zip 文件; 
        删除 本地 dist.zip 文件; 
    

安装

npm i deploy-nginx-xxjss

使用

插件初始化 会在 项目根路径 生成一个配置文件;
    /ssDeploy/deployConfig.js -> 服务器基本信息 和文件存放路径
    /ssDeploy/nginx.conf -> nginx ,配置文件

命令解析

    带有 ‘init’  的命令 表示 该项目初始化命令,主要用于,创建 nginx 运行环境 和项目 存放路径;
    已有 nginx 运行环境 和项目 存放路径 的项目 无需 执行 init 命令;
    
    "zip": "node src/zip.js", // 用于 压缩 dist 包
    
    "nginx": "node src/nginx.js development",// 用于 安装 nginx 环境 并 部署到 远程服务器 -开发环境
    
    "deploy": "yarn build && yarn zip && node src/deploy.js development",//  部署到 远程服务器 -开发环境
    
    "test:nginx": "node src/nginx.js test",// 用于 安装 nginx 环境 并 部署到 远程服务器 -测试环境
    
    "test:deploy": "yarn build && yarn zip && node src/deploy.js test",// 部署到 远程服务器 -测试环境
    
    "pro:nginx": "node src/nginx.js production",// 用于 安装 nginx 环境 并 部署到 远程服务器 -生产环境

    "pro:deploy": "yarn build && yarn zip && node src/deploy.js production"//  部署到 远程服务器 -生产环境

配置 远程服务器

// =============================================== deploy.js==============================

let nginxConfPath = '/usr/local/src/'
// 配置创建安装包目录
let software = '/data/software';
// 配置远程服务器目录
let remoteDirectory = '/data/competition/web';
// 服务地址配置
let serverConfig;

switch (args[0]) {
    case 'production':
        serverConfig = {
            host: '**.***.***.***',
            port: 22,
            username: 'root',
            password: '**************',
        };
        break;
    case 'test':
        serverConfig = {
            host: '**.***.***.***',
            port: 22,
            username: 'root',
            password: '**************',
        };
        break;
    case 'development':
        serverConfig = {
            host: '**.***.***.***',
            port: 22,
            username: 'root',
            password: '**************',
        };
        break;
    default:
        console.error('连接异常:请重新执行dev:deploy、test:deploy、production:deploy');
        process.exit(1);
}
// =============================================== nginx.conf==============================

server {
    listen 80 ;  // 监听端口
    server_name localhost; // 服务器 地址

    location ^~ /{
        root   /path/to your project path /web/dist; // 服务器 前端包地址
        try_files $uri $uri/  /index.html;
    }

    location ^~ /api {
        rewrite ^/api(.*)$ $1 break;
        proxy_pass http://**.**.**; // 服务器 后端代理 地址
    }
}