webpack启动流程


image-20210903154856146

./node_modules/.bin/webpack

image-20210903151045187

./node_modules/webpack/bin/webpack.js

runCli(cli);

image-20210903151518238

image-20210903152801392

webpack-cli/package.json

image-20210903150636053

bin/cli.js

执行runCLi()

image-20210903153242825

webpack-cli/lib/bootstrap.js/runCLi

image-20210903153231172

webpack-cli/lib/webpack-cli.js/constructor()

调用WebpackCLi

image-20210903154402992

引入webpack目的

传入 webpack.config.js 等配置

image-20210903155324975

执行 run 方法目的

调用this.makeCommand

image-20210903155606746

makeCommand内部执行makeOption方法

image-20210903155801295

makeCommand在执行runWebpack方法

runWebpack执行createCompiler

image-20210903150304488

createCompiler传入webpack配置生成 compiler

image-20210903150442697

直接启动webpack

const webpack = require("webpack");
const config = require("../webpack.config");
const compiler = webpack(config);
compiler.run((err, status) => {
  if (err) {
    console.error(err);
  } else {
    console.log(status);
  }
});

执行 node

webpack源码

img

评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.13.0