Skip to content

Migrating from the Asset Pipeline to Webpacker #943

@ryanwood

Description

@ryanwood

I'm attempting to convert a large Rails app from the Asset Pipeline to Webpacker. Instead of a single application.js, there are a number of different top-level JavaScript entry points (dashboard.js, admin.js, etc.). I have two questions:

  1. Is it possible to configure react-rails to use the bundled version of React in the asset pipeline for one top-level JS file (asset pipeline manifest) and use the webpack version for another (pack tag)?
  2. If not, is it possible to force react-rails to use the asset pipeline/bundled React JS even if you have React installed via yarn with Webpack?

I'm trying to find a way to keep parts of the app running under the current react-rails asset pipeline configuration but as soon as I run rails webpacker:install:react, the existing react-rails stuff breaks with Uncaught ReferenceError: React is not defined.

To be clear, the part of the app using the asset pipeline is only has standard stylesheet_link_tags (no pack tags). Yet react-rails is still loading the Webpack (module) version of React, not the bundled version. Is there a way to instruct it to load from one or the other?

Thanks in advance for your help. This is a tricky migration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions