twan
How to install bootstrap in Phoenix 1.4?
How to install bootstrap in my project?
Marked As Solved
kokolegorille
You can reference the relative path too… like this
@import '../node_modules/bootstrap/scss/bootstrap';
@import '../node_modules/font-awesome/css/font-awesome.css';
Please check your path correspond…
At the end of the process, all css are merged into one file by MiniCssExtractPlugin.
Also Liked
lurnid
This is how I got Bootstrap 4.3 installed in Phoenix 1.4:
- In the project’s /assets directory:
$ npm i -D bootstrap
$ npm install --save jquery popper.js
- Add this line to your application’s app.js:
import 'bootstrap’;
- Add a
scssfolder under the /assets folder. - In the
scssfolder, create a file called_custom.scssfor bootstrap settings overrides. - Create a file called
app.scssin that folder and put these lines in it:
@import "../node_modules/bootstrap/scss/bootstrap”; (or you can import individual components)
@import "custom";
- For Bootstrap to compile, make sure you install and use the required loaders: sass-loader, postcss-loader with Autoprefixer. With minimal setup, your webpack config should include this rule or similar:
...
{
test: /\.(scss)$/,
use: [{
loader: 'style-loader', // inject CSS to page
}, {
loader: 'css-loader', // translates CSS into CommonJS modules
}, {
loader: 'postcss-loader', // Run postcss actions
options: {
plugins: function () { // postcss plugins, can be exported to postcss.config.js
return [
require('autoprefixer')
];
}
}
}, {
loader: 'sass-loader' // compiles Sass to CSS
}]
},
…
-
Add this line to your
config/dev.exsso that the contents of theassets/scssfolder you created are watched while you’re developing so that changes are compiled and loaded into theassets/cssfolder -
Now if you fire up your
phx.serverand edit the sass files in theassets/scssfolder, the page should refresh with the changes compiled into the relevant file(s) in theassets/cssfolder
easco
In Phoenix 1.4 the bundler used for JavaScript and CSS assets is Webpack. To integrate Bootstrap into your project, you should look for instructions on installing Bootstrap through Webpack:
The Webpack configuration and sources are found in the assets folder.
sweeneydavidj
Hi,
you can import it at the top of your app.css
for example in mine I have…
@import "./bootstrap.min.css";
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








