Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
babel-plugin-named-asset-import
Advanced tools
Babel plugin for named asset imports in Create React App
The babel-plugin-named-asset-import package is a Babel plugin that allows you to transform certain import statements with a specific naming convention into a different form. This is particularly useful when working with asset files like images, stylesheets, and other static files in a JavaScript or TypeScript project. It can help with customizing the way assets are imported and processed during the build process.
Transforming asset imports
This feature allows you to import an asset, such as an SVG file, in two different forms: as a URL and as a React component. The plugin will transform the import statement so that you can use the asset both as a source for an image tag and as a component in your JSX.
import logoUrl, { ReactComponent as Logo } from './logo.svg';
This package provides similar functionality to babel-plugin-named-asset-import by allowing you to transform import statements for assets into a specified format. It can be configured to return a custom string or a JavaScript object based on the asset's filename, which can be useful for including assets in your bundle.
babel-plugin-inline-import allows you to import text files like GraphQL queries, CSS, or HTML as strings directly into your JavaScript code. This is somewhat similar to babel-plugin-named-asset-import, but instead of transforming the import statement, it inlines the content of the imported file.
While not specifically for assets, babel-plugin-import is designed to modify import statements in a way that can help with tree shaking and reducing bundle sizes. It can be used to import components from libraries in a more granular way, which is a different approach compared to handling static assets but still relates to import statement transformation.
FAQs
Babel plugin for named asset imports in Create React App
The npm package babel-plugin-named-asset-import receives a total of 2,459,481 weekly downloads. As such, babel-plugin-named-asset-import popularity was classified as popular.
We found that babel-plugin-named-asset-import demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.