| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | /* | 
					
						
							|  |  |  | 	MIT License http://www.opensource.org/licenses/mit-license.php
 | 
					
						
							|  |  |  | 	Author Tobias Koppers @sokra | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2015-12-30 00:44:55 +08:00
										 |  |  | var OptionsDefaulter = require("./OptionsDefaulter"); | 
					
						
							| 
									
										
										
										
											2016-01-07 06:02:25 +08:00
										 |  |  | var Template = require("./Template"); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-15 21:16:18 +08:00
										 |  |  | function WebpackOptionsDefaulter() { | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	OptionsDefaulter.call(this); | 
					
						
							|  |  |  | 	this.set("debug", false); | 
					
						
							|  |  |  | 	this.set("devtool", false); | 
					
						
							| 
									
										
										
										
											2014-03-21 23:08:35 +08:00
										 |  |  | 	this.set("cache", true); | 
					
						
							| 
									
										
										
										
											2013-02-26 20:31:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	this.set("context", process.cwd()); | 
					
						
							| 
									
										
										
										
											2013-02-14 00:00:07 +08:00
										 |  |  | 	this.set("target", "web"); | 
					
						
							| 
									
										
										
										
											2013-02-26 20:31:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-03-11 23:08:22 +08:00
										 |  |  | 	this.set("module.unknownContextRequest", "."); | 
					
						
							| 
									
										
										
										
											2015-03-06 04:49:39 +08:00
										 |  |  | 	this.set("module.unknownContextRegExp", false); | 
					
						
							| 
									
										
										
										
											2014-03-11 23:08:22 +08:00
										 |  |  | 	this.set("module.unknownContextRecursive", true); | 
					
						
							|  |  |  | 	this.set("module.unknownContextCritical", true); | 
					
						
							|  |  |  | 	this.set("module.exprContextRequest", "."); | 
					
						
							| 
									
										
										
										
											2015-03-06 04:49:39 +08:00
										 |  |  | 	this.set("module.exprContextRegExp", false); | 
					
						
							| 
									
										
										
										
											2014-03-11 23:08:22 +08:00
										 |  |  | 	this.set("module.exprContextRecursive", true); | 
					
						
							|  |  |  | 	this.set("module.exprContextCritical", true); | 
					
						
							|  |  |  | 	this.set("module.wrappedContextRegExp", /.*/); | 
					
						
							|  |  |  | 	this.set("module.wrappedContextRecursive", true); | 
					
						
							|  |  |  | 	this.set("module.wrappedContextCritical", false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("output", "call", function(value, options) { | 
					
						
							|  |  |  | 		if(typeof value === "string") { | 
					
						
							|  |  |  | 			return { | 
					
						
							|  |  |  | 				filename: value | 
					
						
							|  |  |  | 			}; | 
					
						
							|  |  |  | 		} else if(typeof value !== "object") { | 
					
						
							|  |  |  | 			return {}; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			return value; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2016-01-07 06:02:25 +08:00
										 |  |  | 	this.set("output.filename", "[name].js"); | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("output.chunkFilename", "make", function(options) { | 
					
						
							|  |  |  | 		var filename = options.output.filename; | 
					
						
							|  |  |  | 		return filename.indexOf("[name]") >= 0 ? filename.replace("[name]", "[id]") : "[id]." + filename; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	this.set("output.library", ""); | 
					
						
							|  |  |  | 	this.set("output.hotUpdateFunction", "make", function(options) { | 
					
						
							|  |  |  | 		return Template.toIdentifier("webpackHotUpdate" + options.output.library); | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	this.set("output.jsonpFunction", "make", function(options) { | 
					
						
							|  |  |  | 		return Template.toIdentifier("webpackJsonp" + options.output.library); | 
					
						
							|  |  |  | 	}); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 	this.set("output.libraryTarget", "var"); | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("output.path", process.cwd()); | 
					
						
							| 
									
										
										
										
											2014-04-04 01:46:53 +08:00
										 |  |  | 	this.set("output.sourceMapFilename", "[file].map[query]"); | 
					
						
							| 
									
										
										
										
											2013-12-17 07:56:43 +08:00
										 |  |  | 	this.set("output.hotUpdateChunkFilename", "[id].[hash].hot-update.js"); | 
					
						
							|  |  |  | 	this.set("output.hotUpdateMainFilename", "[hash].hot-update.json"); | 
					
						
							| 
									
										
										
										
											2015-04-17 21:57:42 +08:00
										 |  |  | 	this.set("output.crossOriginLoading", false); | 
					
						
							| 
									
										
										
										
											2013-05-21 17:08:08 +08:00
										 |  |  | 	this.set("output.hashFunction", "md5"); | 
					
						
							|  |  |  | 	this.set("output.hashDigest", "hex"); | 
					
						
							|  |  |  | 	this.set("output.hashDigestLength", 20); | 
					
						
							| 
									
										
										
										
											2014-02-11 15:31:08 +08:00
										 |  |  | 	this.set("output.sourcePrefix", "\t"); | 
					
						
							| 
									
										
										
										
											2015-04-05 07:52:30 +08:00
										 |  |  | 	this.set("output.devtoolLineToLine", false); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("node", {}); | 
					
						
							| 
									
										
										
										
											2013-02-26 20:31:05 +08:00
										 |  |  | 	this.set("node.console", false); | 
					
						
							|  |  |  | 	this.set("node.process", true); | 
					
						
							|  |  |  | 	this.set("node.global", true); | 
					
						
							| 
									
										
										
										
											2015-03-06 04:46:54 +08:00
										 |  |  | 	this.set("node.Buffer", true); | 
					
						
							| 
									
										
										
										
											2015-01-07 01:20:45 +08:00
										 |  |  | 	this.set("node.setImmediate", true); | 
					
						
							| 
									
										
										
										
											2013-02-26 20:31:05 +08:00
										 |  |  | 	this.set("node.__filename", "mock"); | 
					
						
							|  |  |  | 	this.set("node.__dirname", "mock"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("resolve", {}); | 
					
						
							| 
									
										
										
										
											2016-01-27 00:56:44 +08:00
										 |  |  | 	this.set("resolve.unsafeCache", true); | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("resolve.modules", ["node_modules"]); | 
					
						
							|  |  |  | 	this.set("resolve.extensions", [".js", ".json"]); | 
					
						
							|  |  |  | 	this.set("resolve.aliasFields", "make", function(options) { | 
					
						
							|  |  |  | 		if(options.target === "web" || options.target === "webworker") | 
					
						
							|  |  |  | 			return ["browser"]; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return []; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 	this.set("resolve.mainFields", "make", function(options) { | 
					
						
							|  |  |  | 		if(options.target === "web" || options.target === "webworker") | 
					
						
							|  |  |  | 			return ["browser", "web", "browserify", "main"]; | 
					
						
							|  |  |  | 		else | 
					
						
							|  |  |  | 			return ["main"]; | 
					
						
							|  |  |  | 	}); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	this.set("resolveLoader", {}); | 
					
						
							| 
									
										
										
										
											2016-01-27 00:56:44 +08:00
										 |  |  | 	this.set("resolveLoader.unsafeCache", true); | 
					
						
							| 
									
										
										
										
											2016-01-15 02:40:04 +08:00
										 |  |  | 	this.set("resolveLoader.mainFields", ["loader", "main"]); | 
					
						
							|  |  |  | 	this.set("resolveLoader.extensions", [".js", ".json"]); | 
					
						
							|  |  |  | 	this.set("resolveLoader.moduleExtensions", ["-loader"]); | 
					
						
							| 
									
										
										
										
											2013-01-31 01:49:25 +08:00
										 |  |  | } | 
					
						
							|  |  |  | module.exports = WebpackOptionsDefaulter; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | WebpackOptionsDefaulter.prototype = Object.create(OptionsDefaulter.prototype); | 
					
						
							| 
									
										
										
										
											2014-02-13 18:02:31 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | WebpackOptionsDefaulter.prototype.constructor = WebpackOptionsDefaulter; |