webpack启动流程
./node_modules/.bin/webpack
./node_modules/webpack/bin/webpack.js
runCli(cli);
webpack-cli/package.json
bin/cli.js
执行runCLi()
webpack-cli/lib/bootstrap.js/runCLi
webpack-cli/lib/webpack-cli.js/constructor()
调用WebpackCLi
引入webpack
目的
传入 webpack.config.js 等配置
执行 run 方法目的
调用this.makeCommand
makeCommand
内部执行makeOption
方法
makeCommand
在执行runWebpack
方法
runWebpack
执行createCompiler
createCompiler
传入webpack
配置生成 compiler
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
源码
Powered by Waline v2.13.0