Skip to content

Commit bd89d65

Browse files
committed
added resolve.root support
1 parent d75fb7a commit bd89d65

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

‎lib/WebpackOptionsApply.js‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var RemoveEmptyChunksPlugin = require("./optimize/RemoveEmptyChunksPlugin");
3131
var MergeDuplicateChunksPlugin = require("./optimize/MergeDuplicateChunksPlugin");
3232

3333
var ModulesInDirectoriesPlugin = require("enhanced-resolve/lib/ModulesInDirectoriesPlugin");
34+
var ModulesInRootPlugin = require("enhanced-resolve/lib/ModulesInRootPlugin");
3435
var ModuleTemplatesPlugin = require("enhanced-resolve/lib/ModuleTemplatesPlugin");
3536
var ModuleAsFilePlugin = require("enhanced-resolve/lib/ModuleAsFilePlugin");
3637
var ModuleAsDirectoryPlugin = require("enhanced-resolve/lib/ModuleAsDirectoryPlugin");
@@ -105,6 +106,7 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
105106
compiler.resolvers.normal.apply(
106107
new ModuleAliasPlugin(options.resolve.alias),
107108
new ModulesInDirectoriesPlugin("module", options.resolve.modulesDirectories),
109+
makeRootPlugin(options.resolve.root),
108110
new ModuleAsFilePlugin("module"),
109111
new ModuleAsDirectoryPlugin("module"),
110112
new DirectoryDescriptionFilePlugin("package.json", ["webpack", "browserify", "web", ["jam", "main"], "main"]),
@@ -114,13 +116,15 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
114116
compiler.resolvers.context.apply(
115117
new ModuleAliasPlugin(options.resolve.alias),
116118
new ModulesInDirectoriesPlugin("module", options.resolve.modulesDirectories),
119+
makeRootPlugin(options.resolve.root),
117120
new ModuleAsFilePlugin("module"),
118121
new ModuleAsDirectoryPlugin("module"),
119122
new DirectoryResultPlugin()
120123
);
121124
compiler.resolvers.loader.apply(
122125
new ModuleAliasPlugin(options.resolveLoader.alias),
123126
new ModulesInDirectoriesPlugin("loader-module", options.resolveLoader.modulesDirectories),
127+
makeRootPlugin(options.resolveLoader.root),
124128
new ModuleTemplatesPlugin("loader-module", options.resolveLoader.moduleTemplates, "module"),
125129
new ModuleAsFilePlugin("module"),
126130
new ModuleAsDirectoryPlugin("module"),
@@ -130,4 +134,17 @@ WebpackOptionsApply.prototype.process = function(options, compiler) {
130134
);
131135
compiler.applyPlugins("after-resolvers", compiler);
132136
return options;
133-
}
137+
}
138+
139+
function makeRootPlugin(root) {
140+
if(typeof root === "string")
141+
return new ModulesInRootPlugin("module", root);
142+
else if(Array.isArray(root)) {
143+
return function() {
144+
root.forEach(function(root) {
145+
this.apply(new ModulesInRootPlugin("module", root));
146+
}, this);
147+
}
148+
}
149+
return function() {};
150+
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.9.0-beta3",
3+
"version": "0.9.0-beta4",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
66
"dependencies": {

0 commit comments

Comments
 (0)