GitHub 咱們一塊兒學習webpack地址:https://github.com/liangfengbo/learning-webpackwebpack
咱們在命令行中輸入:webpack -h
看看webpack的命令行大全git
Usage: webpack-cli [options] webpack-cli [options] --entry <entry> --output <output> webpack-cli [options] <entries...> --output <output>
webpack告訴咱們,用webpack進行打包有三種方法:es6
1.新建爲webpack.config.js命名的文件,能夠直接webpack命令打包 2.webpack 入口文件<app.js> -o 輸出文件<bundle.js> 3.webpack --config 你自定義的文件名字<webpack-default.js>
// sum.js export default function sum(a, b) { return a + b; }
// app.js // es6 module規範 import sum from './sum' // 調用 console.log('sum(23,24) = ', sum(23, 24));
webpack app.js -o bundle.js
Hash: 7e137d767d2665688484 Version: webpack 4.5.0 Time: 588ms Built at: 2018-6-20 20:30:06 Asset Size Chunks Chunk Names 0.bundle.js 188 bytes 0 [emitted] bundle.js 1.84 KiB 1 [emitted] main Entrypoint main = bundle.js [0] ./app.js + 1 modules 466 bytes {1} [built] | ./app.js 411 bytes [built] | ./sum.js 55 bytes [built] [1] ./minus.js 54 bytes {1} [built] [2] ./muti.js 114 bytes {0} [built]