Skip to content

Commit 8c056de

Browse files
committed
feat(loader): make loader work with webpack 4
1 parent af76123 commit 8c056de

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var loaderUtils = require('loader-utils'),
22
_ = require('lodash'),
3+
path = require('path'),
34
helper = require('./src/helper');
45

56
var defaultOptions = {
@@ -12,8 +13,10 @@ var defaultOptions = {
1213
};
1314

1415
module.exports = function (content, map) {
16+
map = map || {};
17+
1518
var loaderOptions = loaderUtils.getOptions(this);
16-
var inputFile = map.file,
19+
var inputFile = map.file || path.basename(this.resourcePath),
1720
options = _.assign({}, _.cloneDeep(defaultOptions), loaderOptions),
1821
dirPath = this.context,
1922
fileNames = this.fs.readdirSync(dirPath).filter(function (file) {

0 commit comments

Comments
 (0)