import-glob
Advanced tools
Comparing version 1.4.0 to 1.5.0
11
index.js
@@ -6,5 +6,6 @@ var glob = require("glob"); | ||
this.cacheable(); | ||
var regex = /import + ?((\w+) from )?([\'\"])(.*?)\3/gm; | ||
var regex = /.?import + ?((\w+) from )?([\'\"])(.*?)\3/gm; | ||
var importModules = /import +(\w+) +from +([\'\"])(.*?)\2/gm; | ||
var importFiles = /import +([\'\"])(.*?)\1/gm; | ||
var importSass = /@import +([\'\"])(.*?)\1/gm; | ||
var resourceDir = path.dirname(this.resourcePath); | ||
@@ -21,3 +22,5 @@ function replacer(match, fromStatement, obj, quote, filename) { | ||
var fileName = quote + file + quote; | ||
if (match.match(importModules)) { | ||
if (match.match(importSass)) { | ||
return '@import ' + fileName; | ||
} else if (match.match(importModules)) { | ||
var moduleName = obj + index; | ||
@@ -31,5 +34,5 @@ modules.push(moduleName); | ||
}) | ||
.join(';\n'); | ||
.join('; '); | ||
if (result && withModules) { | ||
result += '\nlet ' + obj + ' = [' + modules.join(', ') + ']'; | ||
result += '; let ' + obj + ' = [' + modules.join(', ') + ']'; | ||
} | ||
@@ -36,0 +39,0 @@ return result; |
{ | ||
"name": "import-glob", | ||
"version": "1.4.0", | ||
"version": "1.5.0", | ||
"description": "ES6 import with glob patterns (preloader for Webpack)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -32,3 +32,15 @@ [](https://travis-ci.org/terpiljenya/import-glob) | ||
--- | ||
__For sass:__ | ||
```scss | ||
@import "./foo/**/*.scss"; | ||
``` | ||
Expands into | ||
```scss | ||
@import "./foo/1.scss"; | ||
@import "./foo/bar/2.scss"; | ||
``` | ||
--- | ||
## Install | ||
@@ -48,3 +60,8 @@ ```sh | ||
loader: 'import-glob' | ||
}] | ||
}, | ||
{ | ||
test: /\.scss/, | ||
loader: 'import-glob' | ||
} | ||
] | ||
} | ||
@@ -51,0 +68,0 @@ } |
3836
60
73