| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2016-01-02 07:21:54 +08:00
										 |  |  | var assign = require("object-assign"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 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"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-08-22 19:51:24 +08:00
										 |  |  | var TemplatedPathPlugin = require("./TemplatedPathPlugin"); | 
					
						
							| 
									
										
										
										
											2014-03-31 17:33:17 +08:00
										 |  |  | var WarnCaseSensitiveModulesPlugin = require("./WarnCaseSensitiveModulesPlugin"); | 
					
						
							| 
									
										
										
										
											2016-05-05 23:45:58 +08:00
										 |  |  | var UseStrictPlugin = require("./UseStrictPlugin"); | 
					
						
							| 
									
										
										
										
											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"); | 
					
						
							| 
									
										
										
										
											2015-01-13 00:45:30 +08:00
										 |  |  | var HarmonyModulesPlugin = require("./dependencies/HarmonyModulesPlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-01 06:19:52 +08:00
										 |  |  | var SystemPlugin = require("./dependencies/SystemPlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-05 16:13:50 +08:00
										 |  |  | var EnsureChunkConditionsPlugin = require("./optimize/EnsureChunkConditionsPlugin"); | 
					
						
							| 
									
										
										
										
											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"); | 
					
						
							| 
									
										
										
										
											2015-03-06 04:49:53 +08:00
										 |  |  | var OccurrenceOrderPlugin = require("./optimize/OccurrenceOrderPlugin"); | 
					
						
							| 
									
										
										
										
											2015-10-22 03:05:01 +08:00
										 |  |  | var FlagDependencyUsagePlugin = require("./FlagDependencyUsagePlugin"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-02 07:21:54 +08:00
										 |  |  | var ResolverFactory = require("enhanced-resolve").ResolverFactory; | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | function WebpackOptionsApply() { | 
					
						
							|  |  |  | 	OptionsApply.call(this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | module.exports = WebpackOptionsApply; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WebpackOptionsApply.prototype = Object.create(OptionsApply.prototype); | 
					
						
							| 
									
										
										
										
											2016-05-20 13:39:36 +08:00
										 |  |  | WebpackOptionsApply.prototype.constructor = WebpackOptionsApply; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | WebpackOptionsApply.prototype.process = function(options, compiler) { | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 	var ExternalsPlugin; | 
					
						
							| 
									
										
										
										
											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") { | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 		var JsonpTemplatePlugin; | 
					
						
							|  |  |  | 		var NodeSourcePlugin; | 
					
						
							|  |  |  | 		var NodeTargetPlugin; | 
					
						
							|  |  |  | 		var NodeTemplatePlugin; | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 		switch(options.target) { | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 			case "web": | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 				JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); | 
					
						
							|  |  |  | 				NodeSourcePlugin = require("./node/NodeSourcePlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 				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"); | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 				NodeSourcePlugin = require("./node/NodeSourcePlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new WebWorkerTemplatePlugin(options.output), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeSourcePlugin(options.node), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin("webworker") | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "node": | 
					
						
							|  |  |  | 			case "async-node": | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 				NodeTemplatePlugin = require("./node/NodeTemplatePlugin"); | 
					
						
							|  |  |  | 				NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 				compiler.apply( | 
					
						
							| 
									
										
										
										
											2015-11-21 03:15:03 +08:00
										 |  |  | 					new NodeTemplatePlugin({ | 
					
						
							|  |  |  | 						asyncChunkLoading: options.target === "async-node" | 
					
						
							|  |  |  | 					}), | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeTargetPlugin(), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin("node") | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			case "node-webkit": | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 				JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); | 
					
						
							|  |  |  | 				NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 				ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 				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": | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 			case "electron-main": | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 				NodeTemplatePlugin = require("./node/NodeTemplatePlugin"); | 
					
						
							|  |  |  | 				NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 				ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 				compiler.apply( | 
					
						
							| 
									
										
										
										
											2015-11-21 03:15:03 +08:00
										 |  |  | 					new NodeTemplatePlugin({ | 
					
						
							|  |  |  | 						asyncChunkLoading: true | 
					
						
							|  |  |  | 					}), | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeTargetPlugin(), | 
					
						
							|  |  |  | 					new ExternalsPlugin("commonjs", [ | 
					
						
							|  |  |  | 						"app", | 
					
						
							|  |  |  | 						"auto-updater", | 
					
						
							|  |  |  | 						"browser-window", | 
					
						
							|  |  |  | 						"content-tracing", | 
					
						
							|  |  |  | 						"dialog", | 
					
						
							| 
									
										
										
										
											2015-11-20 11:12:03 +08:00
										 |  |  | 						"electron", | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 						"global-shortcut", | 
					
						
							|  |  |  | 						"ipc", | 
					
						
							| 
									
										
										
										
											2015-12-11 19:15:19 +08:00
										 |  |  | 						"ipc-main", | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 						"menu", | 
					
						
							|  |  |  | 						"menu-item", | 
					
						
							|  |  |  | 						"power-monitor", | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"power-save-blocker", | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 						"protocol", | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"session", | 
					
						
							|  |  |  | 						"web-contents", | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 						"tray", | 
					
						
							|  |  |  | 						"clipboard", | 
					
						
							|  |  |  | 						"crash-reporter", | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"native-image", | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 						"screen", | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"shell" | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 					]), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin(options.target) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 			case "electron-renderer": | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 				JsonpTemplatePlugin = require("./JsonpTemplatePlugin"); | 
					
						
							|  |  |  | 				NodeTargetPlugin = require("./node/NodeTargetPlugin"); | 
					
						
							|  |  |  | 				ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 				compiler.apply( | 
					
						
							|  |  |  | 					new JsonpTemplatePlugin(options.output), | 
					
						
							|  |  |  | 					new FunctionModulePlugin(options.output), | 
					
						
							|  |  |  | 					new NodeTargetPlugin(), | 
					
						
							|  |  |  | 					new ExternalsPlugin("commonjs", [ | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"desktop-capturer", | 
					
						
							| 
									
										
										
										
											2015-11-20 11:12:03 +08:00
										 |  |  | 						"electron", | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 						"ipc", | 
					
						
							| 
									
										
										
										
											2015-12-11 19:15:19 +08:00
										 |  |  | 						"ipc-renderer", | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 						"remote", | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"web-frame", | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 						"clipboard", | 
					
						
							|  |  |  | 						"crash-reporter", | 
					
						
							| 
									
										
										
										
											2016-04-03 16:39:03 +08:00
										 |  |  | 						"native-image", | 
					
						
							| 
									
										
										
										
											2015-09-23 00:05:30 +08:00
										 |  |  | 						"screen", | 
					
						
							|  |  |  | 						"shell" | 
					
						
							|  |  |  | 					]), | 
					
						
							|  |  |  | 					new LoaderTargetPlugin(options.target) | 
					
						
							|  |  |  | 				); | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2015-07-13 06:20:09 +08:00
										 |  |  | 			default: | 
					
						
							|  |  |  | 				throw new Error("Unsupported target '" + options.target + "'."); | 
					
						
							| 
									
										
										
										
											2014-04-09 15:12:04 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} 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"); | 
					
						
							| 
									
										
										
										
											2016-02-27 04:25:53 +08:00
										 |  |  | 		compiler.apply(new LibraryTemplatePlugin(options.output.library, options.output.libraryTarget, options.output.umdNamedDefine, options.output.auxiliaryComment || "")); | 
					
						
							| 
									
										
										
										
											2013-06-19 17:53:03 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-03-05 16:58:51 +08:00
										 |  |  | 	if(options.externals) { | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 		ExternalsPlugin = require("./ExternalsPlugin"); | 
					
						
							| 
									
										
										
										
											2014-03-05 16:58:51 +08:00
										 |  |  | 		compiler.apply(new ExternalsPlugin(options.output.libraryTarget, options.externals)); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2016-04-09 21:51:53 +08:00
										 |  |  | 	var noSources; | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 	var legacy; | 
					
						
							|  |  |  | 	var modern; | 
					
						
							|  |  |  | 	var comment; | 
					
						
							| 
									
										
										
										
											2015-05-19 03:56: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; | 
					
						
							| 
									
										
										
										
											2016-04-09 21:51:53 +08:00
										 |  |  | 		noSources = options.devtool.indexOf("nosources") >= 0; | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 		legacy = options.devtool.indexOf("@") >= 0; | 
					
						
							|  |  |  | 		modern = options.devtool.indexOf("#") >= 0; | 
					
						
							|  |  |  | 		comment = legacy && modern ? "\n/*\n//@ sourceMappingURL=[url]\n//# sourceMappingURL=[url]\n*/" : | 
					
						
							| 
									
										
										
										
											2015-04-07 20:33:57 +08:00
										 |  |  | 			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, | 
					
						
							| 
									
										
										
										
											2016-04-09 21:51:53 +08:00
										 |  |  | 			lineToLine: options.output.devtoolLineToLine, | 
					
						
							|  |  |  | 			noSources: noSources, | 
					
						
							| 
									
										
										
										
											2015-04-05 07:52:30 +08:00
										 |  |  | 		})); | 
					
						
							| 
									
										
										
										
											2015-05-19 03:56:23 +08:00
										 |  |  | 	} else if(options.devtool && options.devtool.indexOf("eval") >= 0) { | 
					
						
							| 
									
										
										
										
											2016-01-19 08:52:28 +08:00
										 |  |  | 		legacy = options.devtool.indexOf("@") >= 0; | 
					
						
							|  |  |  | 		modern = options.devtool.indexOf("#") >= 0; | 
					
						
							|  |  |  | 		comment = legacy && modern ? "\n//@ sourceURL=[url]\n//# sourceURL=[url]" : | 
					
						
							| 
									
										
										
										
											2016-01-05 23:41:59 +08:00
										 |  |  | 			legacy ? "\n//@ sourceURL=[url]" : | 
					
						
							|  |  |  | 			modern ? "\n//# sourceURL=[url]" : | 
					
						
							| 
									
										
										
										
											2015-05-19 03:56:23 +08:00
										 |  |  | 			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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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(), | 
					
						
							| 
									
										
										
										
											2016-05-05 23:45:58 +08:00
										 |  |  | 		new UseStrictPlugin(), | 
					
						
							| 
									
										
										
										
											2013-02-16 00:08:14 +08:00
										 |  |  | 		new RequireIncludePlugin(), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new RequireEnsurePlugin(), | 
					
						
							| 
									
										
										
										
											2016-01-02 07:21:54 +08:00
										 |  |  | 		new RequireContextPlugin(options.resolve.modules, options.resolve.extensions), | 
					
						
							| 
									
										
										
										
											2014-03-11 23:08:22 +08:00
										 |  |  | 		new AMDPlugin(options.module, options.amd || {}), | 
					
						
							| 
									
										
										
										
											2015-01-13 00:45:30 +08:00
										 |  |  | 		new CommonJsPlugin(options.module), | 
					
						
							| 
									
										
										
										
											2015-07-01 06:19:52 +08:00
										 |  |  | 		new HarmonyModulesPlugin(options.module), | 
					
						
							|  |  |  | 		new SystemPlugin(options.module) | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	compiler.apply( | 
					
						
							| 
									
										
										
										
											2016-05-05 16:13:50 +08:00
										 |  |  | 		new EnsureChunkConditionsPlugin(), | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 		new RemoveParentModulesPlugin(), | 
					
						
							|  |  |  | 		new RemoveEmptyChunksPlugin(), | 
					
						
							| 
									
										
										
										
											2013-02-24 09:05:55 +08:00
										 |  |  | 		new MergeDuplicateChunksPlugin(), | 
					
						
							| 
									
										
										
										
											2015-03-06 04:49:53 +08:00
										 |  |  | 		new FlagIncludedChunksPlugin(), | 
					
						
							| 
									
										
										
										
											2015-10-22 03:05:01 +08:00
										 |  |  | 		new OccurrenceOrderPlugin(true), | 
					
						
							|  |  |  | 		new FlagDependencyUsagePlugin() | 
					
						
							| 
									
										
										
										
											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.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
										 |  |  | 
 | 
					
						
							|  |  |  | 	compiler.applyPlugins("after-plugins", compiler); | 
					
						
							| 
									
										
										
										
											2016-01-02 07:21:54 +08:00
										 |  |  | 	compiler.resolvers.normal = ResolverFactory.createResolver(assign({ | 
					
						
							|  |  |  | 		resolver: compiler.resolvers.normal | 
					
						
							|  |  |  | 	}, options.resolve)); | 
					
						
							|  |  |  | 	compiler.resolvers.context = ResolverFactory.createResolver(assign({ | 
					
						
							|  |  |  | 		resolver: compiler.resolvers.context, | 
					
						
							|  |  |  | 		resolveToContext: true | 
					
						
							|  |  |  | 	}, options.resolve)); | 
					
						
							|  |  |  | 	compiler.resolvers.loader = ResolverFactory.createResolver(assign({ | 
					
						
							|  |  |  | 		resolver: compiler.resolvers.loader | 
					
						
							|  |  |  | 	}, options.resolveLoader)); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							| 
									
										
										
										
											2015-04-24 05:55:50 +08:00
										 |  |  | 		}; | 
					
						
							| 
									
										
										
										
											2013-02-04 17:47:00 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 	return function() {}; | 
					
						
							|  |  |  | } |