webpack.01-简单使用

webpack官网:https://webpack.js.org/

全局安装webpack
cnpm i -g webpack webpack-cli
创建index.js
console.log('hello webpack')//示例:建议写es5语法可正常运行,es6需要babel后面做笔记会写
cmd运行
webpack index.js//------>生成文件夹dist,生成文件main.js,会出现下方警告
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: 

官网mode详解:https://webpack.js.org/configuration/mode/

下面两种生成方式无警告(加上mode,默认mode为none)

开发模式development
webpack index.js --mode development//生成文件比较大
生产模式production
webpack index.js --mode production//生成文件小

webpack.02-如何打包

阅读 262

推荐阅读