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') }) ] }