| 
									
										
										
										
											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
										 |  |  | 
 | 
					
						
							|  |  |  | var SingleEntryPlugin = require("./SingleEntryPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 08:44:39 +08:00
										 |  |  | var MultiEntryPlugin = require("./MultiEntryPlugin"); | 
					
						
							| 
									
										
										
										
											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"); | 
					
						
							| 
									
										
										
										
											2013-02-26 19:36:34 +08:00
										 |  |  | var LabeledModulesPlugin = require("./dependencies/LabeledModulesPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 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; | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	if(options.plugins && Array.isArray(options.plugins)) { | 
					
						
							|  |  |  | 		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; | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 	if(typeof options.target === "string") { | 
					
						
							|  |  |  | 		switch(options.target) { | 
					
						
							|  |  |  | 		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"); | 
					
						
							| 
									
										
										
										
											2014-04-10 00:47:59 +08:00
										 |  |  | 			var ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 			compiler.apply( | 
					
						
							|  |  |  | 				new JsonpTemplatePlugin(options.output), | 
					
						
							|  |  |  | 				new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 				new NodeTargetPlugin(), | 
					
						
							|  |  |  | 				new ExternalsPlugin("commonjs", "nw.gui"), | 
					
						
							|  |  |  | 				new LoaderTargetPlugin("node-webkit") | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2014-10-09 15:53:59 +08:00
										 |  |  | 		case "atom": | 
					
						
							| 
									
										
										
										
											2014-10-13 20:10:35 +08:00
										 |  |  | 			var NodeTemplatePlugin = require("./node/NodeTemplatePlugin"); | 
					
						
							| 
									
										
										
										
											2014-10-09 15:53:59 +08:00
										 |  |  | 			var NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 			var ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							|  |  |  | 			compiler.apply( | 
					
						
							| 
									
										
										
										
											2014-10-10 01:37:47 +08:00
										 |  |  | 				new NodeTemplatePlugin(options.output, true), | 
					
						
							| 
									
										
										
										
											2014-10-09 15:53:59 +08:00
										 |  |  | 				new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 				new NodeTargetPlugin(), | 
					
						
							| 
									
										
										
										
											2014-10-12 17:43:10 +08:00
										 |  |  | 				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", | 
					
						
							|  |  |  | 				]), | 
					
						
							| 
									
										
										
										
											2014-10-09 15:53:59 +08:00
										 |  |  | 				new LoaderTargetPlugin("atom") | 
					
						
							|  |  |  | 			); | 
					
						
							|  |  |  | 			break; | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 		default: | 
					
						
							|  |  |  | 			throw new Error("Unsupported target '" + options.target + "'."); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} else if(options.target !== false) { | 
					
						
							|  |  |  | 		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
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +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
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-03-05 16:58:51 +08:00
										 |  |  | 	if(options.externals) { | 
					
						
							|  |  |  | 		var ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							|  |  |  | 		compiler.apply(new ExternalsPlugin(options.output.libraryTarget, options.externals)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-19 19:49:57 +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)); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	if(options.devtool == "eval") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalDevToolModulePlugin(null, options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "@eval") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalDevToolModulePlugin("//@ sourceURL=[url]", options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#eval") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalDevToolModulePlugin("//# sourceURL=[url]", options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#@eval") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalDevToolModulePlugin("//@ sourceURL=[url]\n//# sourceURL=[url]", options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-08-28 21:13:05 +08:00
										 |  |  | 	else if(options.devtool === "hidden-sourcemap" || options.devtool === "hidden-source-map") | 
					
						
							|  |  |  | 		compiler.apply(new SourceMapDevToolPlugin(options.output.sourceMapFilename, false, options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "sourcemap" || options.devtool === "source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(options.output.sourceMapFilename, null, options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "@sourcemap" || options.devtool === "@source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(options.output.sourceMapFilename, "\n/*\n//@ sourceMappingURL=[url]\n*/", options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#sourcemap" || options.devtool === "#source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(options.output.sourceMapFilename, "\n//# sourceMappingURL=[url]", options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#@sourcemap" || options.devtool === "#@source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(options.output.sourceMapFilename, "\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/", options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "inlinesourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "inline-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "inline-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(null, null, options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "@inlinesourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "@inline-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "@inline-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(null, "\n/*\n//@ sourceMappingURL=[url]\n*/", options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#inlinesourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#inline-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#inline-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(null, "\n//# sourceMappingURL=[url]", options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#@inlinesourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#@inline-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#@inline-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new SourceMapDevToolPlugin(null, "\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/", options.output.devtoolModuleFilenameTemplate, options.output.devtoolFallbackModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "evalsourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "eval-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "eval-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalSourceMapDevToolPlugin(null, options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "@evalsourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "@eval-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "@eval-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalSourceMapDevToolPlugin("\n/*\n//@ sourceMappingURL=[url]\n*/", options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#evalsourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#eval-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#eval-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalSourceMapDevToolPlugin("\n//# sourceMappingURL=[url]", options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	else if(options.devtool === "#@evalsourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#@eval-sourcemap" || | 
					
						
							|  |  |  | 			options.devtool === "#@eval-source-map") | 
					
						
							| 
									
										
										
										
											2014-08-14 17:31:05 +08:00
										 |  |  | 		compiler.apply(new EvalSourceMapDevToolPlugin("\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/", options.output.devtoolModuleFilenameTemplate)); | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-31 08:44:39 +08:00
										 |  |  | 	function itemToPlugin(item, name) { | 
					
						
							|  |  |  | 		if(Array.isArray(item)) | 
					
						
							|  |  |  | 			return new MultiEntryPlugin(options.context, item, name); | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return new SingleEntryPlugin(options.context, item, name) | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	if(typeof options.entry === "string" || Array.isArray(options.entry)) { | 
					
						
							| 
									
										
										
										
											2013-01-31 08:44:39 +08:00
										 |  |  | 		compiler.apply(itemToPlugin(options.entry, "main")); | 
					
						
							| 
									
										
										
										
											2014-06-25 00:53:32 +08:00
										 |  |  | 	} else if(typeof options.entry === "object") { | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		Object.keys(options.entry).forEach(function(name) { | 
					
						
							| 
									
										
										
										
											2013-01-31 08:44:39 +08:00
										 |  |  | 			compiler.apply(itemToPlugin(options.entry[name], name)); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		}); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-13 19:34:00 +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()); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +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"); | 
					
						
							|  |  |  | 		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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 05:20:07 +08:00
										 |  |  | 	if(options.cache === undefined ? options.watch : options.cache) { | 
					
						
							|  |  |  | 		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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +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
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 	if(options.define) { | 
					
						
							|  |  |  | 		compiler.apply(new MovedToPluginWarningPlugin("define", "DefinePlugin")); | 
					
						
							| 
									
										
										
										
											2013-09-13 17:17:57 +08:00
										 |  |  | 		var defineObject = {}; | 
					
						
							|  |  |  | 		if(typeof options.define === "object") { | 
					
						
							|  |  |  | 			Object.keys(options.define).forEach(function(key) { | 
					
						
							|  |  |  | 				defineObject[key] = options.define[key]; | 
					
						
							|  |  |  | 			}); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		compiler.apply(new DefinePlugin(defineObject)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-12-18 06:21:49 +08:00
										 |  |  | 	if(options.defineDebug !== false) | 
					
						
							|  |  |  | 		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) { | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 	if(typeof root === "string") | 
					
						
							| 
									
										
										
										
											2013-02-11 03:37:30 +08:00
										 |  |  | 		return new ModulesInRootPlugin(name, root); | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 	else if(Array.isArray(root)) { | 
					
						
							|  |  |  | 		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); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return function() {}; | 
					
						
							|  |  |  | } |