The Angular project does not accept css and js files

Viewed 53

First of all, I apologize that my English is very poor.

Angular. I have added js and CSS files to my JSON file, my js and CSS files are not accepted by my components and it behaves as if there are no css and js files in my project. What is the reason for this?

Edit: ./src/assets/css/style.css" works but for some reason the others don't

Angular.json;

"test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets",
              "src/web.config"
            ],
            "styles": [
              "./src/styles.css",
              "./src/assets/css/style.css",
              "./src/assets/css/ekstra.css",
              "./src/assets/css/nivocomponent.css",
              "./src/assets/css/nivo-slider.css",
              "./src/assets/css/nivodefault.css",
              "./src/assets/fonts/fonts.css",
              "./src/assets/owl-carousel/owl.carousel.css",
              "./src/assets/owl-carousel/owl.theme.css",
              "./src/assets/owl-carousel/assets/js/google-code-prettify/prettify.css",
              "./src/assets/js/magnific-popup/magnific-popup.css",
              "./src/assets/mobilmenu/main.min.css",

              "./node_modules/owl.carousel/dist/assets/owl.carousel.min.css",
              "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
              "./node_modules/sweetalert2/src/sweetalert2.css",
              "./node_modules/bootstrap/dist/css/bootstrap.min.css"

            ],
            "scripts": [
              "./src/assets/js/kaydir.js",
              "./src/assets/mobilmenu/main.min.js",
              "./src/assets/js/jquery-1.11.3.min.js",
              "./node_modules/bootstrap/dist/js/bootstrap.min.js",
              "./node_modules/scorm-again/dist/scorm-again.js",
              "./node_modules/jquery/dist/jquery.min.js",
              "./node_modules/owl.carousel/dist/owl.carousel.min.js"

            ]
          }
        },
2 Answers

You have added JS and CSS, in the wrong place. You have to put it in angular.json under the architect > build section, but it seems you have changed the test section. The test section would be used in ng test command.

Your paths aren't correct somewhere, you have src/assets as well as ./src/assets. One of them is correct. Also, you typically wouldn't store your CSS like that in your assets folder, this will cause it to be copied twice, once for your assets folder and then again for your css.

Related