Skip to content

Commit f883382

Browse files
committed
fix detecting module name for full path @import
User could specify an @import directly to the file (bypassing the style field lookup). For this, we want to use the module name the user specified for prefixing.
1 parent 2d0065d commit f883382

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ function flatten(file, modules) {
5858
// @import "module"
5959
if (name[0] !== '.') {
6060

61+
// if user uses direct path to css file in module
62+
// we pluck the module name from the path start
63+
var pkg_name = name.split('/', 1)[0];
64+
6165
// lookup the entry css file
6266
var filepath = resolve.sync(name, {
6367
basedir: base,
6468
extensions: ['.css'],
6569
packageFilter: function (pkg) {
70+
pkg_name = pkg.name;
6671
pkg.main = pkg.style;
6772
return pkg;
6873
}
@@ -78,7 +83,7 @@ function flatten(file, modules) {
7883
// get required module as a css tree
7984
// replace @import node with new tree
8085
return replace(self.parent.node,
81-
prefix(name, flatten(filepath, modules)));
86+
prefix(pkg_name, flatten(filepath, modules)));
8287
}
8388

8489
var filepath = path.join(base, name);

0 commit comments

Comments
 (0)