webpack.web.js 942 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. MIT License http://www.opensource.org/licenses/mit-license.php
  3. Author Tobias Koppers @sokra
  4. */
  5. "use strict";
  6. const Compiler = require("./Compiler");
  7. const WebEnvironmentPlugin = require("./web/WebEnvironmentPlugin");
  8. const WebpackOptionsApply = require("./WebpackOptionsApply");
  9. const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
  10. const webpack = (options, callback) => {
  11. new WebpackOptionsDefaulter().process(options);
  12. const compiler = new Compiler();
  13. compiler.options = new WebpackOptionsApply().process(options, compiler);
  14. new WebEnvironmentPlugin(
  15. options.inputFileSystem,
  16. options.outputFileSystem
  17. ).apply(compiler);
  18. if (callback) {
  19. compiler.run(callback);
  20. }
  21. return compiler;
  22. };
  23. module.exports = webpack;
  24. webpack.WebpackOptionsDefaulter = WebpackOptionsDefaulter;
  25. webpack.WebpackOptionsApply = WebpackOptionsApply;
  26. webpack.Compiler = Compiler;
  27. webpack.WebEnvironmentPlugin = WebEnvironmentPlugin;