Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

not compatible with hyperloop webpacker recommended setup #3

Open
catmando opened this issue Nov 8, 2017 · 1 comment
Open

not compatible with hyperloop webpacker recommended setup #3

catmando opened this issue Nov 8, 2017 · 1 comment
Milestone

Comments

@catmando
Copy link
Contributor

catmando commented Nov 8, 2017

currently for webpacker the recommendation is to pull in the client_and_server pack via the layout NOT from within the application.rb tree.

However hyper-spec by default assumes everything you need to run is in the application.js file.

The work around is to use the client_option method to force hyper-spec to use the application.html layout (or any other layout you want really) instead of the layout hyper-spec internally generates (which does not include client_and_server)

Perhaps the solution is to add intelligence about webpacker, but also to make the chunks of code generated by for the automatically generated client to be redefinable in your rspec_helper...

So at least as things change, you can temporarily work around.

@catmando catmando added this to the Release 0.15 milestone Nov 15, 2017
@catmando catmando reopened this Nov 15, 2017
@sfcgeorge
Copy link

You need a custom layout to get hyper-spec working with webpacker. Something like:

# app/layouts/hyper_spec.html.haml
!!!
%html
  %head
    = stylesheet_link_tag "application", media: "screen"
    = javascript_include_tag "application"
    = javascript_pack_tag "client_only"
    = javascript_pack_tag "client_and_server"
    = csrf_meta_tags

  %body
    = yield
    :javascript
      $.noConflict();

Hyper Spec includes jQuery in it's output with unfortunately clobbers your app's jQuery so any plugins you loaded stop working. Thus make sure to include the noConflict option as above - it returns your app's jQuery to the $ variable. If you're not using jQuery then take that out.

Also make sure the javascript_pack_tags match what you're actually using in your normal application layout.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants