Skip to content

Commit 34056c4

Browse files
HH
H
authored and
H
committed
feat:
1 parent 99938ed commit 34056c4

File tree

8 files changed

+221
-1
lines changed

8 files changed

+221
-1
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ jspm_packages
3838

3939
tmp
4040
!created-logfile-score.log
41-
.idea
41+
.idea
42+
43+
yarn.lock

code-splitting/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "code-splitting",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC"
12+
}

promise/promise.ecosystem.config.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
module.exports = Promise.resolve({
2+
/**
3+
* Application configuration section
4+
* http://pm2.keymetrics.io/docs/usage/application-declaration/
5+
*/
6+
apps : [
7+
8+
// First application
9+
{
10+
name : "API",
11+
script : "app.js",
12+
env: {
13+
COMMON_VARIABLE: "true"
14+
},
15+
env_production : {
16+
NODE_ENV: "production"
17+
}
18+
}
19+
],
20+
21+
/**
22+
* Deployment section
23+
* http://pm2.keymetrics.io/docs/usage/deployment/
24+
*/
25+
deploy : {
26+
production : {
27+
user : "node",
28+
host : "212.83.163.1",
29+
ref : "origin/master",
30+
repo : "git@github.com:repo.git",
31+
path : "/var/www/production",
32+
"post-deploy" : "npm install && pm2 startOrRestart ecosystem.config.js --env production"
33+
},
34+
dev : {
35+
user : "node",
36+
host : "212.83.163.1",
37+
ref : "origin/master",
38+
repo : "git@github.com:repo.git",
39+
path : "/var/www/development",
40+
"post-deploy" : "npm install && pm2 startOrRestart ecosystem.config.js --env dev",
41+
env : {
42+
NODE_ENV: "dev"
43+
}
44+
}
45+
}
46+
});

promise/promise.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Created by google on 2/4/17.
3+
*/
4+
5+
6+
var conf = require('./promise.ecosystem.config');
7+
8+
9+
10+
// conf.then(function (confObj) {
11+
// resolve(confObj)
12+
// })
13+
14+
15+
function getPromise() {
16+
return new Promise((resolve,reject)=>{
17+
setTimeout(()=>{
18+
console.info('3 seconds');
19+
resolve({err:'服务异常,请重试', data: null})
20+
},3000)
21+
})
22+
}
23+
24+
25+
function getPromise2() {
26+
return getPromise().catch((e)=>{
27+
console.error('eee'+e);
28+
})
29+
}
30+
31+
Promise.all([conf, getPromise2()]).then((data)=>{
32+
console.info(data)
33+
}).catch((e)=>{
34+
console.info(e)
35+
})
36+

webpack2/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
console.info(233)

webpack2/bundle.js

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/******/ (function(modules) { // webpackBootstrap
2+
/******/ // The module cache
3+
/******/ var installedModules = {};
4+
5+
/******/ // The require function
6+
/******/ function __webpack_require__(moduleId) {
7+
8+
/******/ // Check if module is in cache
9+
/******/ if(installedModules[moduleId])
10+
/******/ return installedModules[moduleId].exports;
11+
12+
/******/ // Create a new module (and put it into the cache)
13+
/******/ var module = installedModules[moduleId] = {
14+
/******/ i: moduleId,
15+
/******/ l: false,
16+
/******/ exports: {}
17+
/******/ };
18+
19+
/******/ // Execute the module function
20+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21+
22+
/******/ // Flag the module as loaded
23+
/******/ module.l = true;
24+
25+
/******/ // Return the exports of the module
26+
/******/ return module.exports;
27+
/******/ }
28+
29+
30+
/******/ // expose the modules object (__webpack_modules__)
31+
/******/ __webpack_require__.m = modules;
32+
33+
/******/ // expose the module cache
34+
/******/ __webpack_require__.c = installedModules;
35+
36+
/******/ // identity function for calling harmony imports with the correct context
37+
/******/ __webpack_require__.i = function(value) { return value; };
38+
39+
/******/ // define getter function for harmony exports
40+
/******/ __webpack_require__.d = function(exports, name, getter) {
41+
/******/ if(!__webpack_require__.o(exports, name)) {
42+
/******/ Object.defineProperty(exports, name, {
43+
/******/ configurable: false,
44+
/******/ enumerable: true,
45+
/******/ get: getter
46+
/******/ });
47+
/******/ }
48+
/******/ };
49+
50+
/******/ // getDefaultExport function for compatibility with non-harmony modules
51+
/******/ __webpack_require__.n = function(module) {
52+
/******/ var getter = module && module.__esModule ?
53+
/******/ function getDefault() { return module['default']; } :
54+
/******/ function getModuleExports() { return module; };
55+
/******/ __webpack_require__.d(getter, 'a', getter);
56+
/******/ return getter;
57+
/******/ };
58+
59+
/******/ // Object.prototype.hasOwnProperty.call
60+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
61+
62+
/******/ // __webpack_public_path__
63+
/******/ __webpack_require__.p = "";
64+
65+
/******/ // Load entry module and return exports
66+
/******/ return __webpack_require__(__webpack_require__.s = 0);
67+
/******/ })
68+
/************************************************************************/
69+
/******/ ([
70+
/* 0 */
71+
/***/ (function(module, exports) {
72+
73+
console.info(233)
74+
75+
/***/ })
76+
/******/ ]);

webpack2/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "webpack2",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"build": "webpack --config webpack.config.js"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC",
13+
"devDependencies": {
14+
"webpack": "^2.2.1"
15+
}
16+
}

webpack2/webpack.config.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
function generateConfig(envArgs) {
3+
console.info(envArgs.module)
4+
console.info(envArgs.test)
5+
return {
6+
entry: './app.js',
7+
output: {
8+
filename: 'bundle.js'
9+
}
10+
}
11+
}
12+
13+
function buildConfig(envArgs) {
14+
checkEnvArgs(envArgs)
15+
return generateConfig(envArgs)
16+
}
17+
18+
19+
function checkEnvArgs(envArgs) {
20+
const keys = ['module', 'test'];
21+
keys.map((key)=>{
22+
const value = envArgs[key];
23+
if(!value) {
24+
throw new Error(`环境参数 ${key} 不存在。npm run build --env.module=XXX --env.env=XXX`)
25+
}
26+
})
27+
}
28+
29+
module.exports = buildConfig;
30+
31+
// npm run build -- --env.module=yh-weixin-mall23333 --env.test=test2333

0 commit comments

Comments
 (0)