webpack/lib/webpack.web.js

32 lines
942 B
JavaScript
Raw Normal View History

2013-07-11 05:20:07 +08:00
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const Compiler = require("./Compiler");
const WebEnvironmentPlugin = require("./web/WebEnvironmentPlugin");
const WebpackOptionsApply = require("./WebpackOptionsApply");
const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
2013-07-11 05:20:07 +08:00
const webpack = (options, callback) => {
2013-07-11 05:20:07 +08:00
new WebpackOptionsDefaulter().process(options);
const compiler = new Compiler();
2013-07-11 05:20:07 +08:00
compiler.options = new WebpackOptionsApply().process(options, compiler);
2018-02-25 09:00:20 +08:00
new WebEnvironmentPlugin(
options.inputFileSystem,
options.outputFileSystem
).apply(compiler);
if (callback) {
2013-07-11 05:20:07 +08:00
compiler.run(callback);
}
return compiler;
};
2013-07-11 05:20:07 +08:00
module.exports = webpack;
webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;
webpack.WebpackOptionsApply = WebpackOptionsApply;
webpack.Compiler = Compiler;
webpack.WebEnvironmentPlugin = WebEnvironmentPlugin;