Babel plugin that strips leading/trailing whitespace and indentation whitespace from template literals at build time. Latest version 1.0.4 is stable, with infrequent releases. Key features: customizable whitespace removal via user-defined function, optional verbose logging. Differentiators: lightweight, focused solely on template literal whitespace, works with any Babel setup. Alternatives like babel-plugin-transform-template-literals or manual post-processing are heavier or require additional configuration. Suitable for minifying HTML templates or CSS-in-JS strings.
npm install babel-plugin-remove-template-literals-whitespaceVerified import paths — ran on the pinned version, not inferred.
Demonstrates Babel config with custom fn to aggressively remove leading/trailing whitespace and newlines from template literals.
Ensure your fn function removes all whitespace as needed, e.g., str.replace(/\s+/g, ' ')
If using inside JSX, consider a JSX-specific plugin or manually wrap the template literal in a tagged template.
Use require('babel-plugin-remove-template-literals-whitespace') or string shorthand in plugins array.Define fn as a function that returns a string. Example: (str) => str.trim()
No dependency data recorded yet.