4

I am building an ionic 4 application, and I want to use bootstrap without using the CDN method. I have installed bootstrap with npm install bootstrap.

2
  • Have you followed this? stackoverflow.com/a/50215970/4813913
    – m4n0
    Oct 31, 2018 at 2:43
  • @ManojKumar yes i have its giving this error after adding import "bootstrap" ./src/theme/variables.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/theme/variables.scss) Module build failed: undefined ^ Media query expression must begin with '(' in C:\Users\src\theme\variables.scss (line 6, column 1)
    – tnyamuz
    Oct 31, 2018 at 8:26

4 Answers 4

22

With Ionic 4, this can be done easily by making use of the angular.json file

open the angular.json file, this can be located at the root of your project

locate the the styles array, add the path to the downloaded bootstrap file

"styles": [
          {
            "input": "src/theme/variables.scss"
          },
          {
            "input": "src/global.scss"
          },
          {
            "input": "node_modules/bootstrap/dist/css/bootstrap.min.css"
          }
        ],

if you wish to make use of bootstrap scripts, add the bootstrap script to the scripts array as well.

Please note: for you to make use of bootstrap scripts, jquery and popper.js are required to be added to your projects as well

0
0
  1. create new folder public/css inside ionic app folder.
  2. inside public/css paste copy of bootstrap.min.css.
  3. add "public/css/bootstrap.min.css" string path in angular.json.

*make sure to rebuild your app .>ionic serve

add-bootstrap-to-ionic4_1

add-bootstrap-to-ionic4_2

-2

Just paste the BootstrapCDN into the header of src/index.html.

1
  • 1
    this will require internet connection on mobile device.. remember ionic is also for mobile apps which not necessary have internet connection. Also OP said without using CDN.
    – Carlos.V
    Jun 30, 2019 at 0:11
-7

Go With Links.

1.techiediaries

2.youtube

and rerun ionic 4 using ionic serve

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.