-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add raster image support #410
base: master
Are you sure you want to change the base?
Conversation
1cc342f
to
09f47f1
Compare
lib/utils/is-file-type.js
Outdated
return content.includes('<svg'); | ||
} | ||
|
||
exports.isImage = isImage; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This module file name (is-file-type
) is misleading. I would expect that it exports single function (isFileType
), but it actually the set of utilities to detect file type.
I guess that this file should be renamed to something more appropriate, or, this exports should be split as separate modules.
lib/utils/is-file-type.js
Outdated
|
||
/** | ||
* detect whether content is an image | ||
* @param {Buffer} content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returned value is not documented
lib/utils/is-file-type.js
Outdated
|
||
/** | ||
* detect whether content is an image | ||
* @param {string} content |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returned value
.then((symbol) => { | ||
const runtime = runtimeGenerator({ symbol, config, context: loaderContext.context, loaderContext }); | ||
done(null, runtime); | ||
}).catch(done); | ||
}; | ||
|
||
module.exports.NAMESPACE = NAMESPACE; | ||
|
||
module.exports.raw = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is purpose of this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is purpose of this change?
this will make the first argument of loader become a Buffer
from a string
, so that we can detect whether it is an valid image file using image-size
. (image-size
is also required by svg-baker
so I chose it for detecting image)
09f47f1
to
3dd3e4c
Compare
3dd3e4c
to
16af42a
Compare
What kind of change does this PR introduce? (bugfix, feature, docs update, improvement)
improvement.
What is the current behavior? (You can also link to an open issue here)
Not support raster image.
What is the new behavior (if this is a feature change)?
Support raster image. Close #179
Does this PR introduce a breaking change?
No.
Please check if the PR fulfills contributing guidelines