They perform different operations, but it's often useful to chain them together,
like Unix pipes.
- affix
-loadercould be ommited(省略); - order: right to left;
- *inx
pipe like, chain operation;
| const webpack = require('webpack'); | |
| const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); | |
| module.exports = { | |
| entry = './main.js', | |
| output: { | |
| filename: 'bundle.js', | |
| }, | |
| plugins: [ | |
| new UglifyJsPlugin(); |
They perform different operations, but it's often useful to chain them together,
like Unix pipes.
-loader could be ommited(省略);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; |
| 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) { |