webpack --config
參數進行控制hjs-webpack
、Neutrino
、webpack-blocks
create-react-app
,kyt
,nwb
--env
參數控制分支選擇webpack.base.config.js
webpack.dev.config.js
webpack.prod.config.js
webpack.ssr.config.js
經過
webpack-merge
組合配置css
冒煙測試是指對提交測試的軟件在進行詳細深刻的測試以前而進行的預測試,這種預測試的主要目的 是暴露致使軟件需從新發布的基本功能失效等嚴重問題。html
<type>(<scope>):<subject> <blank line> <body> <blank line> <footer>
type
表明每次提交的類型。全部type類型以下:node
README
,CHANGELOG
,CONTRIBUTE
等等遵照semver規範的優點react
語義化版本規範格式webpack
先行版本號
先行版本號能夠做爲發佈正式版以前的版本,格式是在修訂版本號後面加上一個鏈接號(-),再加上一連串以(.)分割的標識符,
標識符能夠由英文、數字和鏈接號[0-9A-Za-z-]
組成。git
Release Candidate
系統平臺上就是發行候選版本。RC版不會再 加入新的功能了,主要着重於除錯。初級分析: 使用webpack內置的 stats
:構建的統計信息web
package.json中使用stats。正則表達式
"scripts":{ "build:stats":"webpack --env production --json > stats.json", ... }
nodejs中使用算法
const webpack = require("webpack"); const congfig = require("./webpack.config.js")("production"); webpack(config,(err,stats)=> { if(err){ return console.error(err) } if(stats.hasErrors()){ return console.error(stats.toString("errors-only")); } console.log(stats); })
speed-measure-webpack-plugin
:速度分析const SpeedMeasureWebpackPlugin = require("speed-measure-webpack-plugin"); const smp = new SpeedMeasureWebpackPlugin(); const webpackConfig = smp.wrap({ plugins:[ new MyPlugin(), new MyOtherPlugin() ] }) //能夠看到每一個loader和插件執行耗時
webpack-bundle-analyzer
:分析體積const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; module.exports = { plugins:[ new BundleAnalyzerPlugin() ] } //構建完成後會在8888端口展現大小
exports.plugins = { new HappyPack({ id:'jsx', threads:4, loaders:['babel-loader'] }), new HappyPack({ id:'styles', threads:2, loaders: ['style-loader','css-loader','less-loader'] }) }
module.exports = { ..., module:{ rules:[ { test:/.js$/, use:[ { loader:'thread-loader', options:{ workers:3 } }, 'babel-loader' ] } ] } }
parallel-uglify-plugin
插件const ParallelUglifyPlugin = require('webpack-parallel-uglify-plugin'); module.exports = { plugins:[ new ParallelUglifyPlugin({ uglifyJS:{ output:{ beautify:false, comments:false }, compress:{ warning: false, drop_console: true, collapse_vars: true, reduce_vars: true } } }) ] }
uglify-webpack-plugin
開啓 parallele參數。const UglifyPlugin = require('uglify-webpack-plugin'); module.exports = { plugins:[ new UglifyPlugin({ uglifyOptions:{ warning:false, parse:{}, compress:{}, mangle:true, output:null, toplevel: false, nameCache:null, ie8:false, keep_fnames: false }, parallel:true }) ] }
terser-webpack-plugin
開啓parallel參數。const TerserPlugin = require('terser-webpack-plugin'); module.exports = { optimization:{ minimizer:[ new TerserPlugin({ parallel:4 }) ] } }
const HtmlWebpackExternalsPlugin = require('html-webpack-externals-plugin'); plugins:[ new HtmlWebpackExternalsPlugin({ externals:[ { module:'react', entry:'//11.url.cn/now/lib/15.1.0/react-width-addons.min.js?_bid=3123', global:'React' }, { module:'react-dom', entry:'//11.url.cn/now/lib/15.1.0/react-dom.min.js?_bid=3123', global:'ReactDOM' } ] }) ]
const path = reqire('path'); const webpack = require('webpack'); module.exports = { context:process.cwd(), resolve:{ extensions:['.js','.jsx','.json','.less','.css'], modules:[__dirname,'node_modules'] }, entry:{ library:[ 'react', 'react-dom', 'redux', 'react-redux' ] }, output:{ filename:'[name].dll.js', path:path.resolve(__dirname,'./build/library'), library:'[name]' }, plugins:[ new webpack.DllPlugin({ name:'[name]', path:'./build/library/[name].json' }) ] }
webpack.config.js
中使用】module.exports = { plugins:[ new webpack.DllReferencePlugin({ manifest:require('./build/library/manifest.json') }) ] }