Skip to content

Commit 7f1fc5b

Browse files
committed
specify lookup fields in package.json
1 parent 7861570 commit 7f1fc5b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ You can also save this options object in a JSON file and use it with the shell c
463463
// ["", ".webpack.js", ".web.js", ".js"]
464464
// postfixes for files to try
465465

466+
packageMains: ["abc", "main"]
467+
// defaults: ["webpack", "browserify", "main"]
468+
// lookup fields in package.json
469+
466470
loaderExtensions: [".loader.js", ".www-loader.js", "", ".js"],
467471
// defaults: (defaults are NOT included if you define your own)
468472
// [".webpack-web-loader.js", ".webpack-loader.js",
@@ -475,6 +479,10 @@ You can also save this options object in a JSON file and use it with the shell c
475479
// "-web-loader", "-loader", ""]
476480
// postfixes for loader modules to try
477481

482+
loaderPackageMains: ["loader", "main"]
483+
// defaults: ["webpackLoader", "loader", "webpack", "main"]
484+
// lookup fields for loaders in package.json
485+
478486
loaders: [{
479487
test: /\.generator\.js/,
480488
exclude: /\.no\.generator\.js/,

lib/webpack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ module.exports = function webpackMain(context, moduleName, options, callback) {
106106
options.resolve.extensions = ["", ".webpack.js", ".web.js", ".js"];
107107
if(!options.resolve.postfixes)
108108
options.resolve.postfixes = ["", "-webpack", "-web"];
109+
if(!options.resolve.packageMains)
110+
options.resolve.packageMains = ["webpack", "browserify", "main"];
109111
if(!options.resolve.loaderExtensions)
110112
options.resolve.loaderExtensions = [".webpack-web-loader.js", ".webpack-loader.js", ".web-loader.js", ".loader.js", "", ".js"];
111113
if(!options.resolve.loaderPostfixes)
112114
options.resolve.loaderPostfixes = ["-webpack-web-loader", "-webpack-loader", "-web-loader", "-loader", ""];
115+
if(!options.resolve.loaderPackageMains)
116+
options.resolve.loaderPackageMains = ["webpackLoader", "loader", "webpack", "main"];
113117
if(!options.resolve.modulesDirectorys)
114118
options.resolve.modulesDirectorys = ["web_modules", "jam", "node_modules"];
115119
if(!options.resolve.alias)

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.7.9",
3+
"version": "0.7.10",
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 loading of js, json, jade, coffee, css, ... out of the box and more with custom loaders.",
66
"dependencies": {
@@ -9,7 +9,7 @@
99
"uglify-js": "1.2.x",
1010
"sprintf": "0.1.x",
1111
"enhanced-require": "0.3.x",
12-
"enhanced-resolve": "0.2.x",
12+
"enhanced-resolve": "0.3.x",
1313
"raw-loader": "0.2.x",
1414
"json-loader": "0.2.x",
1515
"jade-loader": "0.2.x",

0 commit comments

Comments
 (0)