動態

詳情 返回 返回

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-如何打包

Add a new 評論

Some HTML is okay.