其优势主要可以归类为如下几个:
1. webpack 是以 commonJS 的形式来书写脚本滴,但对 AMD/CMD 的支持也很全面,方便旧项目进行代码迁移。
2. 能被模块化的不仅仅是 JS 了。
3. 开发便捷,能替代部分 grunt/gulp 的工作,比如打包、压缩混淆、图片转base64等。
4. 扩展性强,插件机制完善,特别是支持 React 热插拔(见
react-hot-loader )的功能让人眼前一亮。
In the wild, there are many project structures. Some projects use
app instead of
src. Some projects use
dist or
build instead of
bin. Projects with tests usually use
test,
tests,
spec,
specs or colocate the test files in the source folder.
webpack only supports JavaScript modules natively, but most people will be using a transpiler for ES2015, CoffeeScript, TypeScript, etc. They can be used in webpack by using
loaders.
webpack can only handle JavaScript natively, so we need the
css-loader to process CSS files. We also need the
style-loader to apply the styles in the CSS file.
We don’t want to manually recompile after every change…
webpack --progress --colors --watch
webpack可以说是一个大而全的前端构建工具。它实现了模块化开发和静态文件处理两大问题。