Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit fc8721f

Browse files
chore(deps): migrate on mime-types package (#209)
BREAKING CHANGE: migrate on `mime-types` package, some rare types may have other mimetype
1 parent f13757a commit fc8721f

File tree

4 files changed

+7
-13
lines changed

4 files changed

+7
-13
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ module.exports = {
183183
Type: `String`
184184
Default: `(file extension)`
185185

186-
Sets the MIME type for the file to be transformed. If unspecified the file
187-
extensions will be used to lookup the MIME type.
186+
Sets the MIME type for the file to be transformed. If unspecified the file extensions will be used to lookup the MIME type.
188187

189188
**webpack.config.js**
190189

package-lock.json

Lines changed: 1 addition & 8 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
@@ -48,7 +48,7 @@
4848
},
4949
"dependencies": {
5050
"loader-utils": "^2.0.0",
51-
"mime": "^2.4.4",
51+
"mime-types": "^2.1.26",
5252
"schema-utils": "^2.6.5"
5353
},
5454
"devDependencies": {

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import path from 'path';
2+
13
import { getOptions } from 'loader-utils';
24
import validateOptions from 'schema-utils';
3-
import mime from 'mime';
5+
import mime from 'mime-types';
46

57
import normalizeFallback from './utils/normalizeFallback';
68
import schema from './options.json';
@@ -33,7 +35,7 @@ export default function loader(src) {
3335
// No limit or within the specified limit
3436
if (shouldTransform(options.limit, src.length)) {
3537
const file = this.resourcePath;
36-
const mimetype = options.mimetype || mime.getType(file);
38+
const mimetype = options.mimetype || mime.contentType(path.extname(file));
3739

3840
if (typeof src === 'string') {
3941
// eslint-disable-next-line no-param-reassign

0 commit comments

Comments
 (0)