UNPKG

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