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

@femessage/dockerize-cli

v1.0.1

Published

dockerize your web project in one minute

Downloads

8

Readme

🐳 dockerize-cli

NPM Download NPM Version NPM License PRs Welcome

🔨 前端项目 docker 化利器,帮助你快速的把前端项目打造通过环境变量启动的镜像。

目录

注意事项

环境需求

Node.js 8.x

replace 问题

replace 是通过下载代码中的 url 连接到本地,然后替换这个 url 为本地文件引用来完成替换的。

下载默认会使用 https 协议,如果下载源的 https 证书过期的话,node 会在 SSL 检查的时候帮我们把链接断开。

此时需要在项目根目录增加 dockerize.config.js 配置文件

例子

module.exports = {
  linkesFilter(links, ignores) {
    const ignoreArray = ignores.concat([/https?:\/\/img.t.sinajs.cn/])

    return [...new Set(links)].filter((link) => {
      return !ignoreArray.some((regexp) => regexp.test(link))
    })
  },
  rejectUnauthorized: false, // 容许 https 证书无效
}

使用教程

快速开始

# 在项目根目录执行

# 如果本来项目已经包含了 init 的文件,请参照自己需求修改或者删除自己原本的文件改造

npx @femessage/dockerize-cli init

参数选项

npx @femessage/dockerize-cli replace [dist][public_path]

  1. dist 为目录名
  2. public_path 为上下文地址,默认不填写是 /

把对应的前端构建产物里面的所有网络链接下载到本地,然后替换掉原本的网络链接,使其变成本地静态资源。

ps: 一般私有化部署前端项目,客户环境又不能访问外网的时候有用。

replace

⬆ Back to Top

npx @femessage/dockerize-cli proxy

启动一个静态资源服务器,并且对对应接口提供代理服务,以解决跨域测试 dist 文件的问题

需要配合项目根目录的 dockerize.config.js 启动

在你的根目录创建 dockerize.config.js 文件。

const API_SERVER = 'http:/www.deepexi.api/'

module.exports = {
  // 需要代理的接口
  proxy: {
    '/api': {
      target: API_SERVER,
      changeOrigin: true,
    },
    '/asset-service': API_SERVER,
    '/identity-service': API_SERVER,
    '/openapi': API_SERVER,
    '/cooperation-service': API_SERVER,
  },
  // 静态资源目录
  staticPath: 'dist',
  // 静态资源服务器的端口号
  proxyPort: 9000,
}

⬆ Back to Top

npx @femessage/dockerize-cli init

快速添加 docker 所需相关文件,以及 npm script 到你的项目中

init

具体文件以及 npm script 使用方法可以查看 init 之后,在项目根目录生成的 DOCKER_BUILD.md

⬆ Back to Top

Links

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!