Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summary of Changes to Support React on Rails #594

Closed
justin808 opened this issue Jul 26, 2017 · 2 comments
Closed

Summary of Changes to Support React on Rails #594

justin808 opened this issue Jul 26, 2017 · 2 comments

Comments

@justin808
Copy link
Contributor

justin808 commented Jul 26, 2017

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

@justin808
Copy link
Contributor Author

justin808 commented Jul 26, 2017

@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
Copy link
Contributor Author

@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?

justin808 added a commit to shakacode/shakapacker that referenced this issue Jul 31, 2017
See rails/webpacker#594

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

Summary of changes

* Move base url out from manifest.json to manifest.rb
* Assign env variables to dev server settings so it can be overridden at
  runtime.
* The keys for dev_server should use same format as of now as documented
  in Paths on the README.md. Note that
* 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.
  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
justin808 added a commit to shakacode/shakapacker that referenced this issue Jul 31, 2017
See rails/webpacker#594

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

Summary of changes

* Move base url out from manifest.json to manifest.rb
* Assign env variables to dev server settings so it can be overridden at
  runtime.
* The keys for dev_server should use same format as of now as documented
  in Paths on the README.md. Note that
* 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.
  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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants