Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
babel-plugin-inline-import-data-uri
Advanced tools
Babel plugin to make raw files importable as base64 encoded data URI strings.
Babel plugin to add the opportunity to use import
file content as DataURI.
import logo from './logo.svg';
import background from './background.png';
// Will print "data:image/svg+xml;base64,PD94bWwgdmVyc2lv...4KPC9zdmc+';"
console.log(logo);
class MyComponent extends React.Component
{
render() {
return (
<div style={{background: `url(${background})`}}>
<img src={logo}/>
</div>;
);
}
}
npm install babel-plugin-inline-import-data-uri --save-dev
Add a .babelrc
file and write:
{
"plugins": [
"inline-import-data-uri"
]
}
or pass the plugin with the plugins-flag on CLI
babel-node myfile.js --plugins inline-import-data-uri
By default, Babel-Inline-Import is compatible with the following file extensions:
.svg
.png
If you want to enable different file extensions, you can define them in your .babelrc
file
{
"plugins": [
["inline-import-data-uri", {
"extensions": [
".html",
".jpg"
]
}]
]
}
It inserts the content of the imported file directly into the importing file encoded as Data URI, assigning it to a variable with the same identifier of the import statement, thus replacing the import statement and the file path by its resulting content.
This project is based on babel-plugin-inline-import.
FAQs
Babel plugin to make raw files importable as base64 encoded data URI strings.
The npm package babel-plugin-inline-import-data-uri receives a total of 3,027 weekly downloads. As such, babel-plugin-inline-import-data-uri popularity was classified as popular.
We found that babel-plugin-inline-import-data-uri 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.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.