You’re not receiving notifications from this thread.
How do I install bootstrap-v4 via yarn?
I tried to install bootstrap4 via yarn. And I tried it like this:
- yarn add email@example.com
- rails webpacker:compile
- add the line: *= require bootstrap/dist/css/bootstrap to application.css
But it didn't work out. How do I install bootstrap via yarn? Is it recommended to install bootstrap via yarn? Or is it a better practice to install bootstrap through the bootstrap gem?
Sorry nobody got back to you. I had some trouble doing this myself a while back. As Chris informed me, the webpacker and the asset pipeline are two totally seperate things with similar goals. You don't use them together.
The webpacker documentation may be the best place to look for tutorials. But as a TL;DR I would do the following:
- Add bootstrap through yarn:
yarn add firstname.lastname@example.org
- Create a file to be transpiled by webpacker:
app.sass... whichever name suits you best.)
bootstrap.sassimport your newly added boostrap library:
- In the head of your
<%= stylesheet_pack_tag 'bootstrap' %>.
rails sin one terminal window tab and
./bin/webpack-dev-serverin the other so webpacker can compile your assets and serve them in your app.
Just in case you need an example
I created a sample "hello-world" app following Peter instructions, the only diference is i'm using mini.css instead of bootstrap. It worked like a charm:
Nice! I think it's worth noting now that with webpacker 3.0 you no longer need to run
./bin/webpack-dev-server unless you want features like hot module reloading.
rails s will also compile webpack assets.
How should bootstrap be included instead of using @import ?