nikushi / minipack

Minipack, a gem for minimalists, which can integrates Rails with webpack. It is an alternative to Webpacker.
MIT License
115 stars 22 forks source link

README Update? #37

Open verpixelt opened 4 years ago

verpixelt commented 4 years ago

Hey I just whipped up a quick experiment to see if I get your Gem going with a webpack config. I ran rails newApp --skip-javascript added my webpack config and followed your instructions. The only way I was able to load the main.js file webpack spits out for me was by using <%= javascript_bundle_tag 'main', skip_pipeline: true %> and then add the main.js files to Rails' assets/config/manifest.js file. It took me several tries to get this going. Is this the intended way? Am I doing something wrong? If that's the intended way, would a README edit PR be welcome?

nikushi commented 4 years ago

Thanks to send feedback. I haven’t tried the gem with the recent released Rails so it may not work well even when you follow the instruction written in READM, as you say.

nikushi commented 4 years ago

Why did you need to add the main.js file to assets/config/manifest.js?

verpixelt commented 4 years ago

This happens if I dont

image
anitagraham commented 4 years ago

I'm using minipack with rails 6.0.3.1 and with webpack. To insert the webpack I say

pack_options = {'data-turbolinks-track': 'reload', skip_pipeline: true}
javascript_bundles_with_chunks_tag(pack_name, pack_options)
styleesheet_bundles_with_chunks_tag(pack_name, pack_options)

which seems to be what you have done. I don't touch either the Asset Pipeline manifest or the Minipack manifest (when things are going well. When not going well they often have clues).

The HTML ends up like this: (but with more entries).

<script src="/javascripts/vendors-application-b-60456616.8e14be0fdbe87f877f11.js" data-turbolinks-track="reload"></script>
...
<link rel="stylesheet" media="screen" href="/stylesheets/../stylesheets/2.8e14be0fdbe87f877f11.css" data-turbolinks-track="reload">
...

Rails demands that js be in public/javascripts, and that css be in public/stylesheets. Perhaps I need to look again at my stylesheet path, it does look odd.