Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save georgiybykov/132c06a076f0c6cdc8cd2bf4cbd6e7cc to your computer and use it in GitHub Desktop.

Select an option

Save georgiybykov/132c06a076f0c6cdc8cd2bf4cbd6e7cc to your computer and use it in GitHub Desktop.
How to install Boostrap 4 with Rails 6 without gem / Как прикрутить Boostrap 4 к Rails 6 без gem
КАК ПРИКРУТИТЬ BOOTSTRAP К RAILS 6 (без gem !)
1) Обновляем yarn, ставим последнюю lts версию nodejs (через nvm или “напрямую”).
```
bundle
bundle exec rails webpacker:install
yarn upgrade
yarn install
```
2) Выполняем команду:
```
yarn add bootstrap jquery popper.js
```
3) В папке /app/assets/stylesheets/application.scss(в расширение `scss` из `css`):
```
/*
*= require bootstrap
*/
```
4) В app/views/layouts/application.html.erb:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
...
</body>
</html>
```
5) В config/webpack/environment.js :
```
const { environment } = require('@rails/webpacker')
const webpack = require('webpack')
environment.plugins.append('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery',
Popper: ['popper.js', 'default']
})
)
module.exports = environment
```
6) В app/javascript/packs/application.js :
```
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("jquery")
require("popper.js")
require("bootstrap")
```
ПРОФИТ! :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment