Webpack loader that compiles Embedded Ruby (.erb) template files in Ruby/Rails projects by running them through the Erbubis, Erubi, or ERB gem via a Ruby runner (default: bin/rails runner). Version 5.5.2 supports webpack 2–3 via peer dependency and requires Node >= 0.10.0. Configuration options include dependenciesRoot, engine selection, timeout, and environment variables. Dependencies can be declared via magic comments to enable webpack's watch mode. Suitable for mixed JS/Ruby asset pipelines, notably in Rails apps using Webpacker.
npm install rails-erb-loaderVerified import paths — ran on the pinned version, not inferred.
Configure webpack to preprocess .erb files using rails-erb-loader with custom runner and engine options.
Use an alternative loader (e.g., erb-loader) or stick to webpack 2/3.
Explicitly set dependenciesRoot to the correct path relative to webpack's working directory.
For non-Rails projects, set 'runner' option to 'ruby' and 'engine' to 'erb' in loader options.
Set 'timeoutMs' to a reasonable value (e.g., 10000) to prevent hanging builds.
Use correct comment format: /* rails-erb-loader-dependencies path/to/file */
Run: npm install rails-erb-loader --save-dev
Set runner option to correct path relative to webpack's working directory, or generate binstubs: bundle exec rails app:update:bin
Ensure rule has test: /\.erb$/ and enforce: 'pre' in webpack config.