wearblc
Add Bootstrap and Jquery to Phoenix 1.4 project
I’m trying to add Jquery and Boostrap.js to my project. I’m doing this by downloading the file jquery.js and bootstrap.js and placing them in my vender > js folder.
Do I need to import these files into my app.js file to get them to work? Currently they are not just by adding them to the vendor.js folder.
Do I need to alter my webpack.confid.js file? I wouldn’t think so.
Thanks!
Most Liked
hakimkal
I wrote this guide few months ago, check it out. ~ https://medium.com/wecode-ng/how-to-install-bootstrap-on-phoenix-1-4-project-c8aa724dcdeb
Joep
alvises
What I’ve done so far is to use package.json. In the case of jQuery I’ve added it on assets/package.json in this way
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"jquery": "^3.4.1"
}
and then on the terminal
assets$ npm install
The jQuery library is then downloaded in assets/node_modules and available to be imported on any javascript file. If I create a script like assets/js/custom.js, I can then import jQuery like so
// assets/js/custom.js
import jQuery from "jquery"
jQuery(document).ready(function($){
...
})
and to include the script into the assets pipeline I have to import it in app.js
// assets/js/app.js
import "./custom"
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
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









