Skip to content

Commit c7d7607

Browse files
committed
support loaders as entry module
1 parent 19f2de7 commit c7d7607

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

bin/webpack.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,19 @@ var argv = require("optimist")
7474
var input = argv._[0],
7575
output = argv._[1];
7676

77-
if (input && input[0] !== '/' && input[1] !== ':') {
78-
input = path.join(process.cwd(), input);
77+
var inputFile = input && input.split("!").pop()
78+
if (inputFile && inputFile[0] !== '/' && inputFile[1] !== ':') {
79+
input = input.split("!");
80+
input.pop();
81+
input.push(path.join(process.cwd(), inputFile));
82+
input = input.join("!");
7983
}
84+
var outputFile = output && output.split("!").pop();
8085
if (output && output[0] !== '/' && input[1] !== ':') {
81-
output = path.join(process.cwd(), output);
86+
output = output.split("!");
87+
output.pop();
88+
output.push(path.join(process.cwd(), outputFile));
89+
output = output.join("!");
8290
}
8391

8492
var options = {};

lib/webpack.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,20 @@ module.exports = function(context, moduleName, options, callback) {
6161
if(typeof moduleName === "object") {
6262
callback = options;
6363
options = moduleName;
64-
moduleName = "./" + path.basename(context);
65-
context = path.dirname(context);
64+
context = context.split("!");
65+
var file = context.pop();
66+
context.push("./" + path.basename(file));
67+
moduleName = context.join("!");
68+
context = path.dirname(file);
6669
}
6770
if(typeof moduleName === "function") {
6871
callback = moduleName;
6972
options = {};
70-
moduleName = "./" + path.basename(context);
71-
context = path.dirname(context);
73+
context = context.split("!");
74+
var file = context.pop();
75+
context.push("./" + path.basename(file));
76+
moduleName = context.join("!");
77+
context = path.dirname(file);
7278
}
7379
if(!callback) {
7480
callback = options;

0 commit comments

Comments
 (0)