Registry / devops / babel-plugin-transform-import-ignore

babel-plugin-transform-import-ignore

JSON →
library1.1.0jsnpmunverified

Babel plugin to ignore specific imports (e.g., CSS, SCSS) in Node.js environments, commonly used for server-side rendering. Version 1.1.0 is the latest stable release. Alternates process Webpack's null-loader or similar approaches, but this plugin integrates directly into the Babel pipeline, allowing pattern-based or regex-based ignoring of side-effect imports. It only removes imports that have no assigned variable (e.g., import './style.css'), preserving variable imports. Simple configuration via patterns array with wildcard support.

npm install babel-plugin-transform-import-ignore
INSTALL
IMPORT
SIG · BABEL-PLUGIN-TRANS
B
babel-plugin-transform-import-ignore
devopsjavascriptv1.1.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
plugins: [['babel-plugin-transform-import-ignore', { patterns: ['.css'] }]]
Plugin is added to Babel config, not imported directly in code.

Shows how to configure the plugin in babel.config.js to ignore .css, .scss, and .less imports that have no variable assignment.

// babel.config.js module.exports = { presets: ['@babel/preset-env'], plugins: [ ['babel-plugin-transform-import-ignore', { patterns: ['.css', '.scss', /^\.less$/] }] ] }; // Example input (will be ignored): import './style.css'; // Example output (empty): // (nothing) // Example input (will NOT be ignored): import css from './style.css'; // Example output: unchanged import css from './style.css';
Debug
Known issues
gotchaOnly side-effect imports (no variable assignment) are ignored. Imports like import css from '...' are not affected.
fix
Ensure your import statements are without variable assignment for the plugin to remove them.
affects: all
gotchaWildcard patterns may not work as expected if not using proper glob syntax. Test patterns thoroughly.
fix
Use regex in babel.config.js for more precise matching.
affects: all
Errors
Common errors & fixes
TypeError: Cannot read properties of undefined (reading 'some')
Missing or misconfigured patterns option in plugin config.
fix
Ensure the plugin config includes a 'patterns' array with at least one pattern.
Upgrade
Version history
1.1.0latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency for Babel plugin API
Agent activity
16 hits · last 30 days
node
14
OpenAI (training)
1
Resources
babel-plugin-transform-import-ignore — npm install babel-plugin-transform-import-ignore · libregistry