1.4.7 • Published 3 years ago

app-node-env v1.4.7

Weekly downloads
24
License
MIT
Repository
github
Last release
3 years ago

app-node-env

APP_ENV & one cli tools for customize env of APP's NODE_ENV

https://app-node-env.xgqfrms.xyz

https://www.npmjs.com/package/app-node-env

https://github.com/xgqfrms/app-node-env

$ npm i -g app-node-env
# OR
$ yarn global add app-node-env

Usage

cli

# node
$ ane env=dev
# OR
$ node ane env=dev

demos

  1. custom webpack devServer port
# global install
$ yarn global add app-node-env

# PORT_ENV for webpack
$ ane PORT_ENV=8090
// webpack.config.js
const PORT_ENV = require('./env.js');

console.log('PORT_ENV =', PORT_ENV);

// const ip = require('ip');
// const hostIp = ip.address();
const config = {
  // ...
  devServer: {
    // ...
    // host: hostIp,
    port: PORT_ENV || 8080,
    proxy: [
      {
        context: ['/web/api/'],
        // dev
        target: 'https://web-dev.xgqfrms.xyz',
        // prod
        // target: 'https://web-prod.xgqfrms.xyz',
      },
    ],
  },
};

module.exports = config;
  1. control env
# global install
$ yarn global add app-node-env

# APP_ENV for webpack
$ ane APP_ENV=dev
# $ ane APP_ENV=prod
// webpack.config.js
const APP_ENV = require('./env.js');

console.log('APP_ENV =', APP_ENV);

let target = '';
if(APP_ENV === 'dev') {
  target = 'https://web-dev.xgqfrms.xyz';
} else {
  target = 'https://web-prod.xgqfrms.xyz';
}

const config = {
  // ...
  devServer: {
    // ...
    proxy: [
      {
        context: ['/web/api/'],
        target: target,
        // dev
        // target: 'https://web-dev.xgqfrms.xyz',
        // prod
        // target: 'https://web-prod.xgqfrms.xyz',
      },
    ],
  },
};

module.exports = config;

CJS

node.js module

// CJS
const ANE = require("app-node-env");

(() => {
    ANE();
})();

deploy.sh

#!/bin/bash

#!/usr/bin/env bash

CI

travis-ci

https://travis-ci.org/xgqfrms/app-node-env/builds

https://docs.travis-ci.com/user/getting-started/

.travis.yml

language: node_js

https://docs.travis-ci.com/user/tutorial/#selecting-a-different-programming-language

Travis CI

https://travis-ci.org/github/xgqfrms/app-node-env

https://www.cnblogs.com/xgqfrms/p/12851281.html

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.7

3 years ago

1.3.7

3 years ago

1.3.6

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.3.10

3 years ago

1.3.11

3 years ago

1.3.12

3 years ago

1.3.9

3 years ago

1.3.8

3 years ago

1.3.5

4 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago