Skip to content

Instantly share code, notes, and snippets.

const webpack = require('webpack');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry = './main.js',
output: {
filename: 'bundle.js',
},
plugins: [
new UglifyJsPlugin();

Refer Link

They perform different operations, but it's often useful to chain them together, like Unix pipes.

  1. affix -loader could be ommited(省略);
  2. order: right to left;
  3. *inx pipe like, chain operation;
/*
* Refer: https://github.com/ruanyf/webpack-demos
* demo 3
*/
module.exports = {
entry: './main.jsx',
output: {
filename: 'bundle.js'
},
module: {
/*
* Refer: @jantimon https://github.com/jantimon/html-webpack-plugin/issues/148
* Place javascript in a js folder
* Place css in a css folder
* Place html in the root folder
*/
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: './example.js',
module.export = {
entry: {
'./main1.js',
'./main2.js'
},
output: {
filename: '[name]x.js'
}
}
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
npm config set proxy http://<username>:<password>@<proxy-server-url>:<port>
npm config set https-proxy http://<username>:<password>@<proxy-server-url>:<port>
npm config set proxy 'socks5://127.0.0.1:1080'
npm config set https-proxy 'socks5://127.0.0.1:1080'
var aPromise = new Promise(function (resolve) {
resolve(100);
// promise 1
});
aPromise.then(function (value) {
return value * 2;
// return new Promise | promise 2
});
aPromise.then(function (value) {
return value * 2;
@a1exlism
a1exlism / data_transfer_promise.js
Created February 25, 2018 10:35
// simple calculation with promise-chain // then 会包装成一个新的Promise对象, 并把return作为参数引入
let initNum = 10;
Promise.resolve(initNum).then(function add(num) { // fulfilled function
num += 10;
console.log('add 10 to =>' + num);
return num;
}, function addRej(num) { // onReject
console.log('Reject add operation.');
}).then(function devide(num) {
num /= 4;
function getURL(url) {
return new Promise(function(resolve, reject) {
let req = new XMLHttpRequest();
req.open('GET', url, true);
req.onload = function() {
if (req.status === 200) {
resolve(req.responseText);
} else {
reject(new Error(req.statusText));
}
function asyncFunction() {
return new Promise(function(resolve, reject) {
console.log('Async Hellow World');
resolve('X');
});
}
asyncFunction().then(function (data) {
console.log('Your request was approved, and the variable is ' + data);
}, function(data) {