@@ -12,8 +12,10 @@ const WebpackOptionsDefaulter = require("./WebpackOptionsDefaulter");
1212const validateSchema = require ( "./validateSchema" ) ;
1313const WebpackOptionsValidationError = require ( "./WebpackOptionsValidationError" ) ;
1414const webpackOptionsSchema = require ( "../schemas/WebpackOptions.json" ) ;
15+ const WebpackPresetsApply = require ( "./WebpackPresetsApply" ) ;
1516
1617const webpack = ( options , callback ) => {
18+ console . log ( "WERBPERK" ) ;
1719 const webpackOptionsValidationErrors = validateSchema ( webpackOptionsSchema , options ) ;
1820 if ( webpackOptionsValidationErrors . length ) {
1921 throw new WebpackOptionsValidationError ( webpackOptionsValidationErrors ) ;
@@ -22,8 +24,8 @@ const webpack = (options, callback) => {
2224 if ( Array . isArray ( options ) ) {
2325 compiler = new MultiCompiler ( options . map ( options => webpack ( options ) ) ) ;
2426 } else if ( typeof options === "object" ) {
27+ options = new WebpackPresetsApply ( ) . process ( options ) ;
2528 options = new WebpackOptionsDefaulter ( ) . process ( options ) ;
26-
2729 compiler = new Compiler ( options . context ) ;
2830 compiler . options = options ;
2931 new NodeEnvironmentPlugin ( ) . apply ( compiler ) ;
@@ -41,7 +43,7 @@ const webpack = (options, callback) => {
4143 if ( callback ) {
4244 if ( typeof callback !== "function" ) throw new Error ( "Invalid argument: callback" ) ;
4345 if ( options . watch === true || ( Array . isArray ( options ) && options . some ( o => o . watch ) ) ) {
44- const watchOptions = Array . isArray ( options ) ? options . map ( o => o . watchOptions || { } ) : ( options . watchOptions || { } ) ;
46+ const watchOptions = Array . isArray ( options ) ? options . map ( o => o . watchOptions || { } ) : options . watchOptions || { } ;
4547 return compiler . watch ( watchOptions , callback ) ;
4648 }
4749 compiler . run ( callback ) ;
@@ -71,64 +73,64 @@ const exportPlugins = (obj, mappings) => {
7173} ;
7274
7375exportPlugins ( exports , {
74- " AutomaticPrefetchPlugin" : ( ) => require ( "./AutomaticPrefetchPlugin" ) ,
75- " BannerPlugin" : ( ) => require ( "./BannerPlugin" ) ,
76- " CachePlugin" : ( ) => require ( "./CachePlugin" ) ,
77- " ContextExclusionPlugin" : ( ) => require ( "./ContextExclusionPlugin" ) ,
78- " ContextReplacementPlugin" : ( ) => require ( "./ContextReplacementPlugin" ) ,
79- " DefinePlugin" : ( ) => require ( "./DefinePlugin" ) ,
80- " DllPlugin" : ( ) => require ( "./DllPlugin" ) ,
81- " DllReferencePlugin" : ( ) => require ( "./DllReferencePlugin" ) ,
82- " EnvironmentPlugin" : ( ) => require ( "./EnvironmentPlugin" ) ,
83- " EvalDevToolModulePlugin" : ( ) => require ( "./EvalDevToolModulePlugin" ) ,
84- " EvalSourceMapDevToolPlugin" : ( ) => require ( "./EvalSourceMapDevToolPlugin" ) ,
85- " ExtendedAPIPlugin" : ( ) => require ( "./ExtendedAPIPlugin" ) ,
86- " ExternalsPlugin" : ( ) => require ( "./ExternalsPlugin" ) ,
87- " HashedModuleIdsPlugin" : ( ) => require ( "./HashedModuleIdsPlugin" ) ,
88- " HotModuleReplacementPlugin" : ( ) => require ( "./HotModuleReplacementPlugin" ) ,
89- " IgnorePlugin" : ( ) => require ( "./IgnorePlugin" ) ,
90- " LibraryTemplatePlugin" : ( ) => require ( "./LibraryTemplatePlugin" ) ,
91- " LoaderOptionsPlugin" : ( ) => require ( "./LoaderOptionsPlugin" ) ,
92- " LoaderTargetPlugin" : ( ) => require ( "./LoaderTargetPlugin" ) ,
93- " MemoryOutputFileSystem" : ( ) => require ( "./MemoryOutputFileSystem" ) ,
94- " ModuleFilenameHelpers" : ( ) => require ( "./ModuleFilenameHelpers" ) ,
95- " NamedChunksPlugin" : ( ) => require ( "./NamedChunksPlugin" ) ,
96- " NamedModulesPlugin" : ( ) => require ( "./NamedModulesPlugin" ) ,
97- " NoEmitOnErrorsPlugin" : ( ) => require ( "./NoEmitOnErrorsPlugin" ) ,
98- " NormalModuleReplacementPlugin" : ( ) => require ( "./NormalModuleReplacementPlugin" ) ,
99- " PrefetchPlugin" : ( ) => require ( "./PrefetchPlugin" ) ,
100- " ProgressPlugin" : ( ) => require ( "./ProgressPlugin" ) ,
101- " ProvidePlugin" : ( ) => require ( "./ProvidePlugin" ) ,
102- " SetVarMainTemplatePlugin" : ( ) => require ( "./SetVarMainTemplatePlugin" ) ,
103- " SingleEntryPlugin" : ( ) => require ( "./SingleEntryPlugin" ) ,
104- " SourceMapDevToolPlugin" : ( ) => require ( "./SourceMapDevToolPlugin" ) ,
105- " Stats" : ( ) => require ( "./Stats" ) ,
106- " UmdMainTemplatePlugin" : ( ) => require ( "./UmdMainTemplatePlugin" ) ,
107- " WatchIgnorePlugin" : ( ) => require ( "./WatchIgnorePlugin" ) ,
76+ AutomaticPrefetchPlugin : ( ) => require ( "./AutomaticPrefetchPlugin" ) ,
77+ BannerPlugin : ( ) => require ( "./BannerPlugin" ) ,
78+ CachePlugin : ( ) => require ( "./CachePlugin" ) ,
79+ ContextExclusionPlugin : ( ) => require ( "./ContextExclusionPlugin" ) ,
80+ ContextReplacementPlugin : ( ) => require ( "./ContextReplacementPlugin" ) ,
81+ DefinePlugin : ( ) => require ( "./DefinePlugin" ) ,
82+ DllPlugin : ( ) => require ( "./DllPlugin" ) ,
83+ DllReferencePlugin : ( ) => require ( "./DllReferencePlugin" ) ,
84+ EnvironmentPlugin : ( ) => require ( "./EnvironmentPlugin" ) ,
85+ EvalDevToolModulePlugin : ( ) => require ( "./EvalDevToolModulePlugin" ) ,
86+ EvalSourceMapDevToolPlugin : ( ) => require ( "./EvalSourceMapDevToolPlugin" ) ,
87+ ExtendedAPIPlugin : ( ) => require ( "./ExtendedAPIPlugin" ) ,
88+ ExternalsPlugin : ( ) => require ( "./ExternalsPlugin" ) ,
89+ HashedModuleIdsPlugin : ( ) => require ( "./HashedModuleIdsPlugin" ) ,
90+ HotModuleReplacementPlugin : ( ) => require ( "./HotModuleReplacementPlugin" ) ,
91+ IgnorePlugin : ( ) => require ( "./IgnorePlugin" ) ,
92+ LibraryTemplatePlugin : ( ) => require ( "./LibraryTemplatePlugin" ) ,
93+ LoaderOptionsPlugin : ( ) => require ( "./LoaderOptionsPlugin" ) ,
94+ LoaderTargetPlugin : ( ) => require ( "./LoaderTargetPlugin" ) ,
95+ MemoryOutputFileSystem : ( ) => require ( "./MemoryOutputFileSystem" ) ,
96+ ModuleFilenameHelpers : ( ) => require ( "./ModuleFilenameHelpers" ) ,
97+ NamedChunksPlugin : ( ) => require ( "./NamedChunksPlugin" ) ,
98+ NamedModulesPlugin : ( ) => require ( "./NamedModulesPlugin" ) ,
99+ NoEmitOnErrorsPlugin : ( ) => require ( "./NoEmitOnErrorsPlugin" ) ,
100+ NormalModuleReplacementPlugin : ( ) => require ( "./NormalModuleReplacementPlugin" ) ,
101+ PrefetchPlugin : ( ) => require ( "./PrefetchPlugin" ) ,
102+ ProgressPlugin : ( ) => require ( "./ProgressPlugin" ) ,
103+ ProvidePlugin : ( ) => require ( "./ProvidePlugin" ) ,
104+ SetVarMainTemplatePlugin : ( ) => require ( "./SetVarMainTemplatePlugin" ) ,
105+ SingleEntryPlugin : ( ) => require ( "./SingleEntryPlugin" ) ,
106+ SourceMapDevToolPlugin : ( ) => require ( "./SourceMapDevToolPlugin" ) ,
107+ Stats : ( ) => require ( "./Stats" ) ,
108+ UmdMainTemplatePlugin : ( ) => require ( "./UmdMainTemplatePlugin" ) ,
109+ WatchIgnorePlugin : ( ) => require ( "./WatchIgnorePlugin" )
108110} ) ;
109- exportPlugins ( exports . optimize = { } , {
110- " AggressiveMergingPlugin" : ( ) => require ( "./optimize/AggressiveMergingPlugin" ) ,
111- " AggressiveSplittingPlugin" : ( ) => require ( "./optimize/AggressiveSplittingPlugin" ) ,
112- " ChunkModuleIdRangePlugin" : ( ) => require ( "./optimize/ChunkModuleIdRangePlugin" ) ,
113- " LimitChunkCountPlugin" : ( ) => require ( "./optimize/LimitChunkCountPlugin" ) ,
114- " MinChunkSizePlugin" : ( ) => require ( "./optimize/MinChunkSizePlugin" ) ,
115- " ModuleConcatenationPlugin" : ( ) => require ( "./optimize/ModuleConcatenationPlugin" ) ,
116- " OccurrenceOrderPlugin" : ( ) => require ( "./optimize/OccurrenceOrderPlugin" ) ,
117- " RuntimeChunkPlugin" : ( ) => require ( "./optimize/RuntimeChunkPlugin" ) ,
118- " SideEffectsFlagPlugin" : ( ) => require ( "./optimize/SideEffectsFlagPlugin" ) ,
119- " SplitChunksPlugin" : ( ) => require ( "./optimize/SplitChunksPlugin" ) ,
111+ exportPlugins ( ( exports . optimize = { } ) , {
112+ AggressiveMergingPlugin : ( ) => require ( "./optimize/AggressiveMergingPlugin" ) ,
113+ AggressiveSplittingPlugin : ( ) => require ( "./optimize/AggressiveSplittingPlugin" ) ,
114+ ChunkModuleIdRangePlugin : ( ) => require ( "./optimize/ChunkModuleIdRangePlugin" ) ,
115+ LimitChunkCountPlugin : ( ) => require ( "./optimize/LimitChunkCountPlugin" ) ,
116+ MinChunkSizePlugin : ( ) => require ( "./optimize/MinChunkSizePlugin" ) ,
117+ ModuleConcatenationPlugin : ( ) => require ( "./optimize/ModuleConcatenationPlugin" ) ,
118+ OccurrenceOrderPlugin : ( ) => require ( "./optimize/OccurrenceOrderPlugin" ) ,
119+ RuntimeChunkPlugin : ( ) => require ( "./optimize/RuntimeChunkPlugin" ) ,
120+ SideEffectsFlagPlugin : ( ) => require ( "./optimize/SideEffectsFlagPlugin" ) ,
121+ SplitChunksPlugin : ( ) => require ( "./optimize/SplitChunksPlugin" )
120122} ) ;
121- exportPlugins ( exports . web = { } , {
122- " FetchCompileWasmTemplatePlugin" : ( ) => require ( "./web/FetchCompileWasmTemplatePlugin" ) ,
123- " JsonpTemplatePlugin" : ( ) => require ( "./web/JsonpTemplatePlugin" ) ,
123+ exportPlugins ( ( exports . web = { } ) , {
124+ FetchCompileWasmTemplatePlugin : ( ) => require ( "./web/FetchCompileWasmTemplatePlugin" ) ,
125+ JsonpTemplatePlugin : ( ) => require ( "./web/JsonpTemplatePlugin" )
124126} ) ;
125- exportPlugins ( exports . webworker = { } , {
126- " WebWorkerTemplatePlugin" : ( ) => require ( "./webworker/WebWorkerTemplatePlugin" ) ,
127+ exportPlugins ( ( exports . webworker = { } ) , {
128+ WebWorkerTemplatePlugin : ( ) => require ( "./webworker/WebWorkerTemplatePlugin" )
127129} ) ;
128- exportPlugins ( exports . node = { } , {
129- " NodeTemplatePlugin" : ( ) => require ( "./node/NodeTemplatePlugin" ) ,
130- " ReadFileCompileWasmTemplatePlugin" : ( ) => require ( "./node/ReadFileCompileWasmTemplatePlugin" ) ,
130+ exportPlugins ( ( exports . node = { } ) , {
131+ NodeTemplatePlugin : ( ) => require ( "./node/NodeTemplatePlugin" ) ,
132+ ReadFileCompileWasmTemplatePlugin : ( ) => require ( "./node/ReadFileCompileWasmTemplatePlugin" )
131133} ) ;
132- exportPlugins ( exports . debug = { } , {
133- " ProfilingPlugin" : ( ) => require ( "./debug/ProfilingPlugin" ) ,
134+ exportPlugins ( ( exports . debug = { } ) , {
135+ ProfilingPlugin : ( ) => require ( "./debug/ProfilingPlugin" )
134136} ) ;
0 commit comments