file-loader
Advanced tools
Comparing version 6.1.1 to 6.2.0
@@ -5,2 +5,14 @@ # Changelog | ||
## [6.2.0](https://github.com/webpack-contrib/file-loader/compare/v6.1.1...v6.2.0) (2020-10-27) | ||
### Features | ||
* added the `sourceFilename` property to asset info with original filename ([#393](https://github.com/webpack-contrib/file-loader/issues/393)) ([654e0d6](https://github.com/webpack-contrib/file-loader/commit/654e0d641ec067089f6a2d12e30ec3520f00d808)) | ||
### Bug Fixes | ||
* immutable flag when the `name` option have hash in query string ([#392](https://github.com/webpack-contrib/file-loader/issues/392)) ([381d8bd](https://github.com/webpack-contrib/file-loader/commit/381d8bda3f2494487bfe840386e365b97b6025fe)) | ||
### [6.1.1](https://github.com/webpack-contrib/file-loader/compare/v6.1.0...v6.1.1) (2020-10-09) | ||
@@ -7,0 +19,0 @@ |
@@ -17,2 +17,4 @@ "use strict"; | ||
var _utils = require("./utils"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -28,3 +30,2 @@ | ||
const name = options.name || '[contenthash].[ext]'; | ||
const immutable = /\[([^:\]]+:)?(hash|contenthash)(:[^\]]+)?\]/gi.test(name); | ||
const url = (0, _loaderUtils.interpolateName)(this, name, { | ||
@@ -62,5 +63,21 @@ context, | ||
if (typeof options.emitFile === 'undefined' || options.emitFile) { | ||
this.emitFile(outputPath, content, null, { | ||
immutable | ||
}); | ||
const assetInfo = {}; | ||
if (typeof name === 'string') { | ||
let normalizedName = name; | ||
const idx = normalizedName.indexOf('?'); | ||
if (idx >= 0) { | ||
normalizedName = normalizedName.substr(0, idx); | ||
} | ||
const isImmutable = /\[([^:\]]+:)?(hash|contenthash)(:[^\]]+)?]/gi.test(normalizedName); | ||
if (isImmutable === true) { | ||
assetInfo.immutable = true; | ||
} | ||
} | ||
assetInfo.sourceFilename = (0, _utils.normalizePath)(_path.default.relative(this.rootContext, this.resourcePath)); | ||
this.emitFile(outputPath, content, null, assetInfo); | ||
} | ||
@@ -67,0 +84,0 @@ |
{ | ||
"name": "file-loader", | ||
"version": "6.1.1", | ||
"version": "6.2.0", | ||
"description": "A file loader module for webpack", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
38130
8
164