A Rollup plugin that loads files as plain text strings, akin to Webpack's raw-loader, using a configurable import prefix (default 'inline!'). Version 1.2.7 is the current stable release, published via semantic-release with automated versioning. It supports Node.js 12–16 and works with JavaScript, TypeScript, SVG, and any text-based assets. The plugin integrates seamlessly into Rollup builds, enabling inline injection of file contents into generated bundles—a common pattern in server-side rendering or HTML template generation. Unlike similar plugins, it uses a distinctive import prefix syntax to differentiate inline imports from standard module imports.
npm install rollup-plugin-inline-codeVerified import paths — ran on the pinned version, not inferred.
Shows basic Rollup setup with plugin and usage of the inline prefix to import a JavaScript file's raw content.
Always prepend the prefix to import sources intended for inlining.
Add a global module declaration: declare module 'inline!*' { const inlineCode: string; export default inlineCode; }Use default import syntax: import x from 'inline!./file.js'
Check compatibility with your Rollup version; restrict to known working versions.
Ensure the plugin is added to the plugins array in rollup.config.js and that the import source starts with 'inline!'.
Run 'npm install rollup-plugin-inline-code' and add a global module declaration for 'inline!*'.
Add 'declare module "inline!*" { const inlineCode: string; export default inlineCode; }' to a .d.ts file.