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

ambiences

v1.3.6

Published

多环境webpck、vite plugins配置生成当前环境配置(解决多余IP暴露引起的安全性问题)

Downloads

17

Readme

多环境 webpck\vite plugins 配置生成当前环境配置(解决多余 IP 暴露引起的安全性问 题)。

Install

$ npm install -D ambiences
// or
$ yarn add -D ambiences

Usage

Via .ambiences (Recommended)

  1. [[XXX]] 环境名称,与 package.jsonscripts --mode NODE_ENV 匹配
  2. [xxx] 配置名字,后期系统中调用需要。
  3. xxx=xxx 详细配置

多个环境配置的情况下,这个格式不断重复调整环境参数。

在非build 或者 NODE_ENV=production 并且 outDir 不为空的情况下都会在 outDir 目录下创建对应配置文件可作为外部引入文件处理。

.ambiences

[[dev]] // 环境配置名称
[api] // 参数名称
requestURL = "xxx.xxx.test"
[config] // 参数名称
systemName = "DevTest"
requestURL = "xxx.pro.test"

[[production]]
[api]
requestURL = "xxx.pro.test"
[config]
// 系统名称
qasd = "系统名称"
systemName = "Test";
iiii = 123123
arr = [1,2,3,4,5,6,7,8]
obj = {a:1,b:2,c:3}
isTre = true

package.json

{
	……
	"scripts": {
		"dev": "node ./index.js --mode NODE_ENV=dev",
		"test": "node ./index.js --mode NODE_ENV=test",
		"production": "node ./index.js --mode NODE_ENV=production",
	}
	……
}

ambiences(type?: string,outDir?: string,dev?: DevConfig)

Parameter

| 参数名称 | 类型 | 描述 | 是否必填 | 默认参数 | 备选参数 | | -------- | ----------- | ---------------------------------------------- | -------- | ----------------- | ----------- | | type | string | 打包后需要处理成什么格式的ambiences.config.* | - | json | json/js | | outDir | string | 打包后ambiences.config.*输出到什么位置 | - | dist | - | | dev | DevConfig | 开发环境配置 | - | defineDevConfig | - |

defineDevConfig:DevConfig

| 参数名称 | 类型 | 描述 | 是否必填 | 默认参数 | 备选参数 | | -------- | -------- | -------------------------------- | -------- | -------- | --------------------- | | env | string | 开发环境需要什么amb.*类型文件 | - | js | jsx/js/ts/tsx | | path | string | 开发环境中配置文件输出到什么目录 | - | src | - | | isPro | boolen | 当前是否为生产版本 | - | false | - |

Plugins Use

import ambiences from 'ambiences';
module.exports = {
	……
	"plugins": [
		ambiences('js', "dist")
	],
	……
}

// or

import {ambiences,DevConfig} from 'ambiences';
const ambiencesDevConfig:DevConfig = {
	// 项目目录
	inputDir: '',
	// 开发环境需要什么amb.*类型文件,可选 ts、tsx、js、jsx
    env: "js",
    // 开发环境中配置文件输出到什么目录
    path: "src/config",
    // 当前是否为生产版本
    isPro: false
}
module.exports = {
	……
	"plugins": [
		ambiences('js', "dist",ambiencesDevConfig)
	],
	……
}

ambiences production

|--dist
	|-- ……
	|-- ambiences.config.js
	|-- ……

production 环境为例

ambiences.config.js
var ambiences = {
	ENV: 'production',
	api: {
		requestURL: 'http://xxx.api.pro.com',
	},
	config: {
		systemName: 'Production system name',
	},
};
ambiences.config.json
{
	"ENV": "production",
	"api": {
		"requestURL": "http://xxx.api.pro.com"
	},
	"config": {
		"systemName": "Production system name"
	}
}

ambiences development

|--src
	|-- ……
	|-- ambiences.config.js
	|-- ……

dev 环境为例

ambiences.config.js
export const ENV = 'dev';
export const api = {
	requestURL: 'http://xxx.api.dev.com',
};
export const config = {
	systemName: 'DevDependencies system name',
};

export default { api, config, ENV };

问题反馈

在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流