
Security News
New React Server Components Vulnerabilities: DoS and Source Code Exposure
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.
grunt-encode-asset-base64
Advanced tools
grunt plugin to encode assets to base64 data URI scheme for embedding to JavaScript code
$ npm install grunt-encode-asset-base64
var grunt = require("grunt");
module.exports = function(){
grunt.initConfig({
assetenc: {
map: {
"json": function(filepath){
return JSON.stringify(JSON.parse(require("fs").readFileSync(filepath)));
},
"bmp": "image/bmp"
},
pathToAssets: "path/to/assets",
rootAlias: "assets",
dst: "assets/assets.js",
template: "assets/assets.template.js"
}
});
grunt.loadNpmTasks('grunt-encode-asset-base64');
};
$ grunt assetenc
assetenc: {
map: {
"expr": "mime/types", // add expression to encode to data URI scheme with mime type.
"json": function(filepath){
return JSON.stringify(JSON.parse(require("fs").readFileSync(filepath)));
// if you want some specified result, write your process. given [filepath].
}
}, // default: {}
pathToAssets: "path/to/assets", // required
rootAlias: "assets", // default: processed pathToAssets(omit '.', '..', './', '../' at the beginning of path)
dst: "assets/assets.js", // required. output file goes here(override if exists)
template: "assets/assets.template.js" // required. lodash template style.
}
var Assets = {};
<% Object.keys(assets).forEach(function(key){%>
Assets['<%= key %>'] = '<%= this[key] %>';
<% }, assets); %>
dirs
assets
|-Hoge
||-A.jpg
|-Fuga
||-FugaFuga
|||-B.png
results
var Assets = {};
Assets['assets/Hoge/A'] = 'data:image/jpeg;base64,....';
Assets['assets/Fuga/FugaFuga/B'] = 'data:image/png;base64,.... ';
MIT
FAQs
asset(s) encode to base64.
We found that grunt-encode-asset-base64 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.