| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							|  |  |  | var OptionsApply = require("./OptionsApply"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | var LoaderTargetPlugin = require("./LoaderTargetPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | var FunctionModulePlugin = require("./FunctionModulePlugin"); | 
					
						
							|  |  |  | var EvalDevToolModulePlugin = require("./EvalDevToolModulePlugin"); | 
					
						
							| 
									
										
										
										
											2013-03-26 23:54:41 +08:00
										 |  |  | var SourceMapDevToolPlugin = require("./SourceMapDevToolPlugin"); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:40:16 +08:00
										 |  |  | var EvalSourceMapDevToolPlugin = require("./EvalSourceMapDevToolPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 00:27:59 +08:00
										 |  |  | var EntryOptionPlugin = require("./EntryOptionPlugin"); | 
					
						
							| 
									
										
										
										
											2013-05-31 18:22:40 +08:00
										 |  |  | var RecordIdsPlugin = require("./RecordIdsPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | var APIPlugin = require("./APIPlugin"); | 
					
						
							|  |  |  | var ConstPlugin = require("./ConstPlugin"); | 
					
						
							| 
									
										
										
										
											2013-02-14 04:24:00 +08:00
										 |  |  | var RequireJsStuffPlugin = require("./RequireJsStuffPlugin"); | 
					
						
							| 
									
										
										
										
											2013-02-14 00:00:07 +08:00
										 |  |  | var NodeStuffPlugin = require("./NodeStuffPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | var CompatibilityPlugin = require("./CompatibilityPlugin"); | 
					
						
							| 
									
										
										
										
											2013-09-13 17:17:57 +08:00
										 |  |  | var DefinePlugin = require("./DefinePlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | var MovedToPluginWarningPlugin = require("./MovedToPluginWarningPlugin"); | 
					
						
							| 
									
										
										
										
											2014-08-22 19:51:24 +08:00
										 |  |  | var TemplatedPathPlugin = require("./TemplatedPathPlugin"); | 
					
						
							| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | var WarnCaseSensitiveModulesPlugin = require("./WarnCaseSensitiveModulesPlugin"); | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-28 23:21:29 +08:00
										 |  |  | var LoaderPlugin = require("./dependencies/LoaderPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | var CommonJsPlugin = require("./dependencies/CommonJsPlugin"); | 
					
						
							|  |  |  | var AMDPlugin = require("./dependencies/AMDPlugin"); | 
					
						
							|  |  |  | var RequireContextPlugin = require("./dependencies/RequireContextPlugin"); | 
					
						
							|  |  |  | var RequireEnsurePlugin = require("./dependencies/RequireEnsurePlugin"); | 
					
						
							| 
									
										
										
										
											2013-02-16 00:08:14 +08:00
										 |  |  | var RequireIncludePlugin = require("./dependencies/RequireIncludePlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | var RemoveParentModulesPlugin = require("./optimize/RemoveParentModulesPlugin"); | 
					
						
							|  |  |  | var RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin"); | 
					
						
							|  |  |  | var MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin"); | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | var FlagIncludedChunksPlugin = require("./optimize/FlagIncludedChunksPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-04 18:01:10 +08:00
										 |  |  | var UnsafeCachePlugin = require("enhanced-resolve/lib/UnsafeCachePlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | var ModulesInDirectoriesPlugin = require("enhanced-resolve/lib/ModulesInDirectoriesPlugin"); | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | var ModulesInRootPlugin = require("enhanced-resolve/lib/ModulesInRootPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | var ModuleTemplatesPlugin = require("enhanced-resolve/lib/ModuleTemplatesPlugin"); | 
					
						
							|  |  |  | var ModuleAsFilePlugin = require("enhanced-resolve/lib/ModuleAsFilePlugin"); | 
					
						
							|  |  |  | var ModuleAsDirectoryPlugin = require("enhanced-resolve/lib/ModuleAsDirectoryPlugin"); | 
					
						
							|  |  |  | var ModuleAliasPlugin = require("enhanced-resolve/lib/ModuleAliasPlugin"); | 
					
						
							|  |  |  | var DirectoryDefaultFilePlugin = require("enhanced-resolve/lib/DirectoryDefaultFilePlugin"); | 
					
						
							|  |  |  | var DirectoryDescriptionFilePlugin = require("enhanced-resolve/lib/DirectoryDescriptionFilePlugin"); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:02:31 +08:00
										 |  |  | var DirectoryDescriptionFileFieldAliasPlugin = require("enhanced-resolve/lib/DirectoryDescriptionFileFieldAliasPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | var FileAppendPlugin = require("enhanced-resolve/lib/FileAppendPlugin"); | 
					
						
							|  |  |  | var DirectoryResultPlugin = require("enhanced-resolve/lib/DirectoryResultPlugin"); | 
					
						
							| 
									
										
										
										
											2015-01-18 04:57:28 +08:00
										 |  |  | var ResultSymlinkPlugin = require("enhanced-resolve/lib/ResultSymlinkPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function WebpackOptionsApply() { | 
					
						
							|  |  |  | 	OptionsApply.call(this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = WebpackOptionsApply; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WebpackOptionsApply.prototype = Object.create(OptionsApply.prototype); | 
					
						
							|  |  |  | WebpackOptionsApply.prototype.process = function(options, compiler) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 	compiler.context = options.context; | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.plugins && Array.isArray(options.plugins)) { | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		compiler.apply.apply(compiler, options.plugins); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	compiler.outputPath = options.output.path; | 
					
						
							| 
									
										
										
										
											2013-05-31 18:22:40 +08:00
										 |  |  | 	compiler.recordsInputPath = options.recordsInputPath || options.recordsPath; | 
					
						
							|  |  |  | 	compiler.recordsOutputPath = options.recordsOutputPath || options.recordsPath; | 
					
						
							| 
									
										
										
										
											2014-06-12 04:26:50 +08:00
										 |  |  | 	compiler.name = options.name; | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(typeof options.target === "string") { | 
					
						
							|  |  |  | 		switch(options.target) { | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 			case "web": | 
					
						
							|  |  |  | 				var JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); | 
					
						
							|  |  |  | 				var NodeSourcePlugin = require("./node/NodeSourcePlugin"); | 
					
						
							|  |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new JsonpTemplatePlugin(options.output), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeSourcePlugin(options.node), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin("web") | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "webworker": | 
					
						
							|  |  |  | 				var WebWorkerTemplatePlugin = require("./webworker/WebWorkerTemplatePlugin"); | 
					
						
							|  |  |  | 				var NodeSourcePlugin = require("./node/NodeSourcePlugin"); | 
					
						
							|  |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new WebWorkerTemplatePlugin(options.output), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeSourcePlugin(options.node), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin("webworker") | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "node": | 
					
						
							|  |  |  | 			case "async-node": | 
					
						
							|  |  |  | 				var NodeTemplatePlugin = require("./node/NodeTemplatePlugin"); | 
					
						
							|  |  |  | 				var NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new NodeTemplatePlugin(options.output, options.target === "async-node"), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeTargetPlugin(), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin("node") | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "node-webkit": | 
					
						
							|  |  |  | 				var JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); | 
					
						
							|  |  |  | 				var NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 				var ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							|  |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new JsonpTemplatePlugin(options.output), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeTargetPlugin(), | 
					
						
							|  |  |  | 					new ExternalsPlugin("commonjs", "nw.gui"), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin("node-webkit") | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "atom": | 
					
						
							|  |  |  | 			case "electron": | 
					
						
							|  |  |  | 				var NodeTemplatePlugin = require("./node/NodeTemplatePlugin"); | 
					
						
							|  |  |  | 				var NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 				var ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							|  |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new NodeTemplatePlugin(options.output, true), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeTargetPlugin(), | 
					
						
							|  |  |  | 					new ExternalsPlugin("commonjs", [ | 
					
						
							|  |  |  | 						"app", | 
					
						
							|  |  |  | 						"auto-updater", | 
					
						
							|  |  |  | 						"browser-window", | 
					
						
							|  |  |  | 						"content-tracing", | 
					
						
							|  |  |  | 						"dialog", | 
					
						
							|  |  |  | 						"global-shortcut", | 
					
						
							|  |  |  | 						"ipc", | 
					
						
							|  |  |  | 						"menu", | 
					
						
							|  |  |  | 						"menu-item", | 
					
						
							|  |  |  | 						"power-monitor", | 
					
						
							|  |  |  | 						"protocol", | 
					
						
							|  |  |  | 						"tray", | 
					
						
							|  |  |  | 						"remote", | 
					
						
							|  |  |  | 						"web-view", | 
					
						
							|  |  |  | 						"clipboard", | 
					
						
							|  |  |  | 						"crash-reporter", | 
					
						
							|  |  |  | 						"screen", | 
					
						
							|  |  |  | 						"shell" | 
					
						
							|  |  |  | 					]), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin(options.target) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			default: | 
					
						
							|  |  |  | 				throw new Error("Unsupported target '" + options.target + "'."); | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	} else if(options.target !== false) { | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 		options.target(compiler); | 
					
						
							|  |  |  | 	} else { | 
					
						
							| 
									
										
										
										
											2014-02-11 15:53:32 +08:00
										 |  |  | 		throw new Error("Unsupported target '" + options.target + "'."); | 
					
						
							| 
									
										
										
										
											2013-02-14 00:00:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.output.library || options.output.libraryTarget !== "var") { | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var LibraryTemplatePlugin = require("./LibraryTemplatePlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget)); | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.externals) { | 
					
						
							| 
									
										
										
										
											2014-03-05 16:58:51 +08:00
										 |  |  | 		var ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							|  |  |  | 		compiler.apply(new ExternalsPlugin(options.output.libraryTarget, options.externals)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.hot) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("hot", "HotModuleReplacementPlugin")); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var HotModuleReplacementPlugin = require("./HotModuleReplacementPlugin"); | 
					
						
							| 
									
										
										
										
											2013-06-19 19:49:57 +08:00
										 |  |  | 		compiler.apply(new HotModuleReplacementPlugin(options.output)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0)) { | 
					
						
							| 
									
										
										
										
											2015-04-07 20:33:57 +08:00
										 |  |  | 		var hidden = options.devtool.indexOf("hidden") >= 0; | 
					
						
							|  |  |  | 		var inline = options.devtool.indexOf("inline") >= 0; | 
					
						
							|  |  |  | 		var evalWrapped = options.devtool.indexOf("eval") >= 0; | 
					
						
							|  |  |  | 		var cheap = options.devtool.indexOf("cheap") >= 0; | 
					
						
							|  |  |  | 		var moduleMaps = options.devtool.indexOf("module") >= 0; | 
					
						
							|  |  |  | 		var legacy = options.devtool.indexOf("@") >= 0; | 
					
						
							|  |  |  | 		var modern = options.devtool.indexOf("#") >= 0; | 
					
						
							|  |  |  | 		var comment = legacy && modern ? "\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/" : | 
					
						
							|  |  |  | 			legacy ? "\n/*\n//@ sourceMappingURL=[url]\n*/" : | 
					
						
							|  |  |  | 			modern ? "\n//# sourceMappingURL=[url]" : | 
					
						
							|  |  |  | 			null; | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 		var Plugin = evalWrapped ? EvalSourceMapDevToolPlugin : SourceMapDevToolPlugin; | 
					
						
							|  |  |  | 		compiler.apply(new Plugin({ | 
					
						
							| 
									
										
										
										
											2015-04-07 20:33:57 +08:00
										 |  |  | 			filename: inline ? null : options.output.sourceMapFilename, | 
					
						
							| 
									
										
										
										
											2015-04-05 07:52:30 +08:00
										 |  |  | 			moduleFilenameTemplate: options.output.devtoolModuleFilenameTemplate, | 
					
						
							|  |  |  | 			fallbackModuleFilenameTemplate: options.output.devtoolFallbackModuleFilenameTemplate, | 
					
						
							| 
									
										
										
										
											2015-04-07 20:33:57 +08:00
										 |  |  | 			append: hidden ? false : comment, | 
					
						
							|  |  |  | 			module: moduleMaps ? true : cheap ? false : true, | 
					
						
							|  |  |  | 			columns: cheap ? false : true, | 
					
						
							|  |  |  | 			lineToLine: options.output.devtoolLineToLine | 
					
						
							| 
									
										
										
										
											2015-04-05 07:52:30 +08:00
										 |  |  | 		})); | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	} else if(options.devtool && options.devtool.indexOf("eval") >= 0) { | 
					
						
							| 
									
										
										
										
											2015-05-19 03:56:23 +08:00
										 |  |  | 		var legacy = options.devtool.indexOf("@") >= 0; | 
					
						
							|  |  |  | 		var modern = options.devtool.indexOf("#") >= 0; | 
					
						
							|  |  |  | 		var comment = legacy && modern ? "//@ sourceURL=[url]\n//# sourceURL=[url]" : | 
					
						
							|  |  |  | 			legacy ? "//@ sourceURL=[url]" : | 
					
						
							|  |  |  | 			modern ? "//# sourceURL=[url]" : | 
					
						
							|  |  |  | 			null; | 
					
						
							|  |  |  | 		compiler.apply(new EvalDevToolModulePlugin(comment, options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2015-04-07 20:33:57 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-17 00:27:59 +08:00
										 |  |  | 	compiler.apply(new EntryOptionPlugin()); | 
					
						
							|  |  |  | 	compiler.applyPluginsBailResult("entry-option", options.context, options.entry); | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.prefetch) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("prefetch", "PrefetchPlugin")); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var PrefetchPlugin = require("./PrefetchPlugin"); | 
					
						
							| 
									
										
										
										
											2013-05-13 19:34:00 +08:00
										 |  |  | 		options.prefetch.map(function(request) { | 
					
						
							|  |  |  | 			compiler.apply(new PrefetchPlugin(options.context, request)); | 
					
						
							|  |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	compiler.apply( | 
					
						
							|  |  |  | 		new CompatibilityPlugin(), | 
					
						
							| 
									
										
										
										
											2013-10-28 23:21:29 +08:00
										 |  |  | 		new LoaderPlugin(), | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		new NodeStuffPlugin(options.node), | 
					
						
							| 
									
										
										
										
											2013-02-14 04:24:00 +08:00
										 |  |  | 		new RequireJsStuffPlugin(), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new APIPlugin(), | 
					
						
							|  |  |  | 		new ConstPlugin(), | 
					
						
							| 
									
										
										
										
											2013-02-16 00:08:14 +08:00
										 |  |  | 		new RequireIncludePlugin(), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new RequireEnsurePlugin(), | 
					
						
							|  |  |  | 		new RequireContextPlugin(options.resolve.modulesDirectories, options.resolve.extensions), | 
					
						
							| 
									
										
										
										
											2014-03-11 23:08:22 +08:00
										 |  |  | 		new AMDPlugin(options.module, options.amd || {}), | 
					
						
							|  |  |  | 		new CommonJsPlugin(options.module) | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	compiler.apply( | 
					
						
							|  |  |  | 		new RemoveParentModulesPlugin(), | 
					
						
							|  |  |  | 		new RemoveEmptyChunksPlugin(), | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | 		new MergeDuplicateChunksPlugin(), | 
					
						
							|  |  |  | 		new FlagIncludedChunksPlugin() | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	); | 
					
						
							| 
									
										
										
										
											2013-05-08 19:28:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-22 19:51:24 +08:00
										 |  |  | 	compiler.apply(new TemplatedPathPlugin()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-31 18:22:40 +08:00
										 |  |  | 	compiler.apply(new RecordIdsPlugin()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | 	compiler.apply(new WarnCaseSensitiveModulesPlugin()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.optimize && options.optimize.occurenceOrder) { | 
					
						
							| 
									
										
										
										
											2014-02-25 15:51:40 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("optimize.occurenceOrder", "optimize.OccurrenceOrderPlugin")); | 
					
						
							|  |  |  | 		var OccurrenceOrderPlugin = require("./optimize/OccurrenceOrderPlugin"); | 
					
						
							|  |  |  | 		compiler.apply(new OccurrenceOrderPlugin(options.optimize.occurenceOrderPreferEntry)); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-05-08 19:28:54 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.optimize && options.optimize.minChunkSize) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("optimize.minChunkSize", "optimize.MinChunkSizePlugin")); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var MinChunkSizePlugin = require("./optimize/MinChunkSizePlugin"); | 
					
						
							| 
									
										
										
										
											2013-06-18 00:55:11 +08:00
										 |  |  | 		compiler.apply(new MinChunkSizePlugin(options.optimize)); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-02-11 17:52:19 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.optimize && options.optimize.maxChunks) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("optimize.maxChunks", "optimize.LimitChunkCountPlugin")); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var LimitChunkCountPlugin = require("./optimize/LimitChunkCountPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		compiler.apply(new LimitChunkCountPlugin(options.optimize)); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.optimize.minimize) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("optimize.minimize", "optimize.UglifyJsPlugin")); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var UglifyJsPlugin = require("./optimize/UglifyJsPlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 		if(options.optimize.minimize === true) | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 			compiler.apply(new UglifyJsPlugin()); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		else | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 			compiler.apply(new UglifyJsPlugin(options.optimize.minimize)); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.cache === undefined ? options.watch : options.cache) { | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var CachePlugin = require("./CachePlugin"); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 		compiler.apply(new CachePlugin(typeof options.cache === "object" ? options.cache : null)); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(typeof options.provide === "object") { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("provide", "ProvidePlugin")); | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 		var ProvidePlugin = require("./ProvidePlugin"); | 
					
						
							| 
									
										
										
										
											2014-02-25 15:48:51 +08:00
										 |  |  | 		compiler.apply(new ProvidePlugin(options.provide)); | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.define) { | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("define", "DefinePlugin")); | 
					
						
							| 
									
										
										
										
											2013-09-13 17:17:57 +08:00
										 |  |  | 		var defineObject = {}; | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 		if(typeof options.define === "object") { | 
					
						
							| 
									
										
										
										
											2013-09-13 17:17:57 +08:00
										 |  |  | 			Object.keys(options.define).forEach(function(key) { | 
					
						
							|  |  |  | 				defineObject[key] = options.define[key]; | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		compiler.apply(new DefinePlugin(defineObject)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(options.defineDebug !== false) | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 		compiler.apply(new DefinePlugin({ | 
					
						
							|  |  |  | 			DEBUG: !!options.debug | 
					
						
							|  |  |  | 		})); | 
					
						
							| 
									
										
										
										
											2013-09-13 17:17:57 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	compiler.applyPlugins("after-plugins", compiler); | 
					
						
							|  |  |  | 	compiler.resolvers.normal.apply( | 
					
						
							| 
									
										
										
										
											2013-07-04 18:01:10 +08:00
										 |  |  | 		new UnsafeCachePlugin(options.resolve.unsafeCache), | 
					
						
							| 
									
										
										
										
											2014-02-11 19:24:41 +08:00
										 |  |  | 		options.resolve.packageAlias ? new DirectoryDescriptionFileFieldAliasPlugin("package.json", options.resolve.packageAlias) : function() {}, | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new ModuleAliasPlugin(options.resolve.alias), | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		makeRootPlugin("module", options.resolve.root), | 
					
						
							| 
									
										
										
										
											2013-02-04 20:59:43 +08:00
										 |  |  | 		new ModulesInDirectoriesPlugin("module", options.resolve.modulesDirectories), | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		makeRootPlugin("module", options.resolve.fallback), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new ModuleAsFilePlugin("module"), | 
					
						
							|  |  |  | 		new ModuleAsDirectoryPlugin("module"), | 
					
						
							| 
									
										
										
										
											2013-10-13 04:08:04 +08:00
										 |  |  | 		new DirectoryDescriptionFilePlugin("package.json", options.resolve.packageMains), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new DirectoryDefaultFilePlugin(["index"]), | 
					
						
							| 
									
										
										
										
											2015-01-18 04:57:28 +08:00
										 |  |  | 		new FileAppendPlugin(options.resolve.extensions), | 
					
						
							|  |  |  | 		new ResultSymlinkPlugin() | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	); | 
					
						
							|  |  |  | 	compiler.resolvers.context.apply( | 
					
						
							| 
									
										
										
										
											2013-07-04 18:01:10 +08:00
										 |  |  | 		new UnsafeCachePlugin(options.resolve.unsafeCache), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new ModuleAliasPlugin(options.resolve.alias), | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		makeRootPlugin("module", options.resolve.root), | 
					
						
							| 
									
										
										
										
											2013-02-04 20:59:43 +08:00
										 |  |  | 		new ModulesInDirectoriesPlugin("module", options.resolve.modulesDirectories), | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		makeRootPlugin("module", options.resolve.fallback), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new ModuleAsFilePlugin("module"), | 
					
						
							|  |  |  | 		new ModuleAsDirectoryPlugin("module"), | 
					
						
							| 
									
										
										
										
											2015-01-18 04:57:28 +08:00
										 |  |  | 		new DirectoryResultPlugin(), | 
					
						
							|  |  |  | 		new ResultSymlinkPlugin() | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	); | 
					
						
							|  |  |  | 	compiler.resolvers.loader.apply( | 
					
						
							| 
									
										
										
										
											2013-07-04 18:01:10 +08:00
										 |  |  | 		new UnsafeCachePlugin(options.resolve.unsafeCache), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new ModuleAliasPlugin(options.resolveLoader.alias), | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		makeRootPlugin("loader-module", options.resolveLoader.root), | 
					
						
							| 
									
										
										
										
											2013-02-04 20:59:43 +08:00
										 |  |  | 		new ModulesInDirectoriesPlugin("loader-module", options.resolveLoader.modulesDirectories), | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		makeRootPlugin("loader-module", options.resolveLoader.fallback), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new ModuleTemplatesPlugin("loader-module", options.resolveLoader.moduleTemplates, "module"), | 
					
						
							|  |  |  | 		new ModuleAsFilePlugin("module"), | 
					
						
							|  |  |  | 		new ModuleAsDirectoryPlugin("module"), | 
					
						
							| 
									
										
										
										
											2013-10-13 04:08:04 +08:00
										 |  |  | 		new DirectoryDescriptionFilePlugin("package.json", options.resolveLoader.packageMains), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new DirectoryDefaultFilePlugin(["index"]), | 
					
						
							| 
									
										
										
										
											2015-01-18 04:57:28 +08:00
										 |  |  | 		new FileAppendPlugin(options.resolveLoader.extensions), | 
					
						
							|  |  |  | 		new ResultSymlinkPlugin() | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	); | 
					
						
							|  |  |  | 	compiler.applyPlugins("after-resolvers", compiler); | 
					
						
							|  |  |  | 	return options; | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | function makeRootPlugin(name, root) { | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	if(typeof root === "string") | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		return new ModulesInRootPlugin(name, root); | 
					
						
							| 
									
										
										
										
											2015-07-16 06:19:23 +08:00
										 |  |  | 	else if(Array.isArray(root)) { | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 		return function() { | 
					
						
							|  |  |  | 			root.forEach(function(root) { | 
					
						
							| 
									
										
										
										
											2013-02-11 18:10:15 +08:00
										 |  |  | 				this.apply(new ModulesInRootPlugin(name, root)); | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 			}, this); | 
					
						
							| 
									
										
										
										
											2015-04-24 05:55:50 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return function() {}; | 
					
						
							|  |  |  | } |