Skip to content

Commit 7e80709

Browse files
committed
Merge remote-tracking branch 'origin/master' into media-queries
2 parents 0bf11a9 + 51e34f3 commit 7e80709

File tree

7 files changed

+25
-2
lines changed

7 files changed

+25
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
node_modules
1+
node_modules/*
2+
!node_modules/cool-styles
23
lib

node_modules/cool-styles/foo.css

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-modules-loader-core",
3-
"version": "0.0.11",
3+
"version": "0.0.12",
44
"description": "A loader-agnostic CSS Modules implementation, based on PostCSS",
55
"main": "lib/index.js",
66
"directories": {

src/file-system-loader.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ export default class FileSystemLoader {
3636
rootRelativePath = path.resolve( relativeDir, newPath ),
3737
fileRelativePath = path.resolve( path.join( this.root, relativeDir ), newPath )
3838

39+
// if the path is not relative or absolute, try to resolve it in node_modules
40+
if (newPath[0] !== '.' && newPath[0] !== '/') {
41+
try {
42+
fileRelativePath = require.resolve(newPath);
43+
}
44+
catch (e) {}
45+
}
46+
3947
const tokens = this.tokensByFile[fileRelativePath]
4048
if (tokens) { return resolve(tokens) }
4149

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
._compose_node_module_cool_styles_foo__example {
2+
color: #F00;
3+
}
4+
._compose_node_module_source__foo {
5+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"foo": "_compose_node_module_source__foo _compose_node_module_cool_styles_foo__example"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.foo {
2+
composes: example from "cool-styles/foo.css";
3+
}

0 commit comments

Comments
 (0)