webpack2 和 3有那些區別?
兩者之間語法差異大嗎?
性能提升大嗎?有必要升級3嗎?
webpack 3 was a breaking change for internal API"s only. Although this does mean that some users may find certain plugins may break. We"ve seen a high percentage of individuals who have successfully upgraded with no problems at all.
The reason we released webpack 3 so quickly is because we made a promise that we were going to ship a much faster and consistent, and stable release cycle. So instead of thinking webpack 3, 4, 5, 6, 7, 8, you can just consider it another version of webpack.
The main feature that was released with this version of webpack is called (in english) "Scope Hoisting".
If you inspect the output of webpack"s code, you will notice that every module is wrapped in a function. These functions make code slower to evaluate by all of the JavaScript engines (V8, JavaScriptCore, SpiderMonkey, and ChakraCore). What "Scope Hoisting" does, is take all ES6 style modules, and concatenate them together, renames all conflicting variables and then puts any of the modules under one function. This makes code execute in the browser much quicker.
So although you will not see a large bundle size decrease, you should see your webpack bundles executing faster at runtime!!
You can use this feature (recommended for production builds only) using
webpack.optimize.ModuleConcatenationPlugin()
webpack 到目前為止已經走過了三個大版本,每個版本之間都,增加了非常多可用的特性,但是每個版本的具體配置項都有些差異,很容易讓老版本用戶形成依賴。現在 webpack 3 已經走到了 3.8 版本。現版本對於 webpack 2.x 的配置項來說,最突出的就是 loader 的寫法的改變和內置了 webpack-dev-server 的特性。
升不升級,應該是看你們組老闆怎麼想,以及,你們項目裡面的自定義的 plugin 多不多等等。對於性能來說, webpack3 打包起來非常的順暢,而且,現在已經內置了很多分方便的調試工具,比如 dev-server。
具體可以參考一下:看啥雙拱門,來學 webpack 3啊 | villianHR
個人理解,主要改動是將es6的代碼,不再按照文件,module的方式分開打包,而是打包進一個module。提升載入速度,對文件大小影響不大
推薦閱讀:
※使用vue-cli,還有必要學習webpack嗎?
※vue.js不用yeoman怎麼搭建工程化結構?另外常用的vue的包又有哪些
TAG:webpack |