From c71d3863b88c98636c950b2d1cfa54a4fbc901bd Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 17 Mar 2020 15:25:44 +0300 Subject: [PATCH 1/2] chore(deps): migrate on `mime-types` package BREAKING CHANGE: migrate on `mime-types` package --- package-lock.json | 9 +-------- package.json | 2 +- src/index.js | 6 ++++-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 088f10f..e365c7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10265,22 +10265,15 @@ "brorand": "^1.0.1" } }, - "mime": { - "version": "2.4.4", - "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", - "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" - }, "mime-db": { "version": "1.43.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.43.0.tgz", - "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==", - "dev": true + "integrity": "sha512-+5dsGEEovYbT8UY9yD7eE4XTc4UwJ1jBYlgaQQF38ENsKR3wj/8q8RFZrF9WIZpB2V1ArTVFUva8sAul1NzRzQ==" }, "mime-types": { "version": "2.1.26", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.26.tgz", "integrity": "sha512-01paPWYgLrkqAyrlDorC1uDwl2p3qZT7yl806vW7DvDoxwXi46jsjFbg+WdwotBIk6/MbEhO/dh5aZ5sNj/dWQ==", - "dev": true, "requires": { "mime-db": "1.43.0" } diff --git a/package.json b/package.json index 6f001e3..4eaf604 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ }, "dependencies": { "loader-utils": "^2.0.0", - "mime": "^2.4.4", + "mime-types": "^2.1.26", "schema-utils": "^2.6.5" }, "devDependencies": { diff --git a/src/index.js b/src/index.js index be68d24..faf9202 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,8 @@ +import path from 'path'; + import { getOptions } from 'loader-utils'; import validateOptions from 'schema-utils'; -import mime from 'mime'; +import mime from 'mime-types'; import normalizeFallback from './utils/normalizeFallback'; import schema from './options.json'; @@ -33,7 +35,7 @@ export default function loader(src) { // No limit or within the specified limit if (shouldTransform(options.limit, src.length)) { const file = this.resourcePath; - const mimetype = options.mimetype || mime.getType(file); + const mimetype = options.mimetype || mime.contentType(path.extname(file)); if (typeof src === 'string') { // eslint-disable-next-line no-param-reassign From d1d1d9ea5e5515595810e379e814b79fea337c38 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Tue, 17 Mar 2020 15:26:37 +0300 Subject: [PATCH 2/2] chore(deps): migrate on `mime-types` package BREAKING CHANGE: migrate on `mime-types` package --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index fb3cc51..ea1dd4e 100644 --- a/README.md +++ b/README.md @@ -183,8 +183,7 @@ module.exports = { Type: `String` Default: `(file extension)` -Sets the MIME type for the file to be transformed. If unspecified the file -extensions will be used to lookup the MIME type. +Sets the MIME type for the file to be transformed. If unspecified the file extensions will be used to lookup the MIME type. **webpack.config.js**