rollup-plugin-inline-js

raw JSON →
0.5.0 verified Mon Apr 27 auth: no javascript

Rollup plugin to inline static assets at build time using inline-js directives. Version 0.5.0 supports Rollup ^2.38.5. It replaces $inline directives in source files, similar to the inline-js CLI. The plugin is maintained but has infrequent updates. Key differentiators: it works as a transform plugin, allowing inline directives directly in source code rather than requiring a separate processing step.

error Error: The plugin "rollup-plugin-inline-js" is not compatible with this version of Rollup! Expected: ^2.38.5
cause Rollup version mismatch.
fix
Update rollup to ^2.38.5.
error TypeError: inline is not a function
cause Using CommonJS require() instead of ES import.
fix
Use import inline from 'rollup-plugin-inline-js' (ESM) instead of require().
error Error: No configuration found for inline-js
cause Missing or misconfigured .inline.js file or inlineOptions.
fix
Ensure .inline.js file is present or provide inlineOptions in plugin configuration.
breaking Upgrade to rollup@2.38.5 required; older versions incompatible.
fix Update rollup to ^2.38.5 and plugin to 0.5.0.
breaking Plugin rewritten in 0.3.0; $inline directives now transform source files instead of using a different mechanism.
fix Migrate to use $inline directives in source code directly.
gotcha Node.js >=8 required; older versions may fail.
fix Use Node.js 8 or later.
deprecated Dependencies array deprecated; use include/exclude instead.
fix Remove dependencies array from plugin options.
npm install rollup-plugin-inline-js
yarn add rollup-plugin-inline-js
pnpm add rollup-plugin-inline-js

Shows how to configure the plugin in a Rollup config file with include/exclude patterns and inline options.

import inline from 'rollup-plugin-inline-js';

export default {
  input: 'src/entry.js',
  output: {
    file: 'dist/bundle.js',
    format: 'esm'
  },
  plugins: [
    inline({
      include: ['*.js'],
      exclude: ['node_modules/**'],
      inlineOptions: { /* inline-js-core options */ }
    })
  ]
};