Skip to content

Summary of Changes to Support React on Rails #594

Closed
@justin808

Description

@justin808
Contributor

From a long discussion on #464, this issue will summarize. I'll soon be posting proposed changes to the README.md.

Demo: https://github.com/justin808/webpacker-demo-webpacker_lite-merge

Summary of changes

  1. Move base url out from manifest.json to manifest.rb
  2. Assign env variables to dev server settings so it can be overridden at runtime.
  3. The keys for dev_server should use same format as of now as documented in Paths on the README.md. Note that
  4. hot is a new setting to indicate that the dev_server is used with hot reloading, which means that CSS should be inlined to be hot loaded.
  5. The presence of dev_server means that the webpack-dev-server is used for the given env.
development:
   # put the created files to the /public/webpack/development directory
  public_output_path: webpack/development

 # if dev_server is not provided, then dev_server is not used
 dev_server: 
   hot: true # This is a new setting
   static: false
   host: localhost
   https: false

CC: @gauravtiwari

Activity

justin808

justin808 commented on Jul 26, 2017

@justin808
ContributorAuthor

@gauravtiwari, React on Rails will handle compilation of files separately than the bin/webpack task.
Thus, the caching for compilation won't work (without some changes).

Instead, React on Rails needs the check if the bundle is created, per this line.

So I have a lookup method that does not necessarily throw, and will trigger the loading of the instance.

Please let me know your thoughts on this one.

Maybe if the API changes are minimal, we can release a beta version of the Webpacker gem that works with React on Rails, and then we can assess the next step.

In React on Rails.

      def stale_generated_webpack_files
        manifest_needed = ReactOnRails::Utils.using_webpacker_lite? &&
                          !WebpackerLite::Manifest.exist?

        return ["manifest.json"] if manifest_needed

        most_recent_mtime = find_most_recent_mtime
        all_compiled_assets.each_with_object([]) do |webpack_generated_file, stale_gen_list|
          if !File.exist?(webpack_generated_file) ||
             File.mtime(webpack_generated_file) < most_recent_mtime
            stale_gen_list << webpack_generated_file
          end
          stale_gen_list
        end
      end
justin808

justin808 commented on Jul 29, 2017

@justin808
ContributorAuthor

@gauravtiwari @dhh,
I added a demo: https://github.com/justin808/webpacker-demo-webpacker_lite-merge. My next step is to create a beta of React on Rails that depends on this version of Webpacker. Is there anything you'd like to see me do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

        Participants

        @gauravtiwari@justin808

        Issue actions

          Summary of Changes to Support React on Rails · Issue #594 · rails/webpacker