Open catmando opened 4 years ago
See the answer on the SO site.
Note sure if everything works quite, right, but the basic answer is that you want to have both <%= style_sheet_pack_tag 'xxxx' %>
AND <%= javascript_pack_tag 'xxx' %>
In development the stylesheet pack tag will do nothing, and the style sheets will be injected via the javascript_pack_tag. During production the stylesheet will get its own package...
Its all to make hot loading via webpacker work.
Need to test to see if hyper-spec works with all this...
to get things to work with hyper-spec you need to do two things:
extract_css: true
under the test heading in the webpacker.yml fileoption layout: 'application'
in the test spec (you can do it in before(:each)
for example.)We should try and see what happens if you directly use <%= javascript_pack_tag ... %> in side hyperspec component controller...
In
config/webpacker.yml
theextract_css
option is currently false unless in production, but this seems to break importing predefined styles.Should it be true?
In the meantime if you are trying to include styles from an npm module (i.e. bootstrap) do the following:
app/javascript/packs/styles.js
file and import the style sheets you want.<%= style_sheet_pack_tag 'styles' %>
to your layout files.extract_css: true
inconfig/webpacker.yml
Currently trying to find an answer to why this is all necessary here: https://stackoverflow.com/questions/59009216/how-to-get-webpacker-to-load-css-if-extract-css-is-false