> For the complete documentation index, see [llms.txt](https://wisdom.gitbook.io/gyan/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wisdom.gitbook.io/gyan/angular/skip-scss-and-test-files-in-angular-with-ng-generate.md).

# Skip SCSS and Test Files in Angular with ng generate

In Angular, when using `ng generate` (or `ng g`), files like **test files** (`.spec.ts`) and **style files** (like `.scss`) are generated by default. However, if you want to skip generating **test files** for all entities (e.g., components, services) and generate **only one global SCSS file**, here's how you can customize the Angular CLI behavior.

### Steps to Skip Test Files and SCSS Files for Components

#### 1. **Skip Test Files (`.spec.ts`)**

To skip generating test files for components, services, pipes, etc., configure this in your `angular.json` file under each schematic type.

**Add This Configuration to `angular.json`:**

```json
{
  "projects": {
    "your-project-name": {
      "schematics": {
        "@schematics/angular:component": {
          "skipTests": true,
          "styleExt": "none"
        },
        "@schematics/angular:directive": {
          "skipTests": true,
          "styleExt": "none"
        },
        "@schematics/angular:service": {
          "skipTests": true
        },
        "@schematics/angular:pipe": {
          "skipTests": true
        },
        "@schematics/angular:class": {
          "skipTests": true
        },
        "@schematics/angular:guard": {
          "skipTests": true
        },
        "@schematics/angular:resolver": {
          "skipTests": true
        }
      }
    }
  }
}
```

This configuration ensures that no **`.spec.ts` files** are generated when running `ng generate` commands for components, services, guards, and more.

**2. Global SCSS File**

Angular automatically generates a global `styles.scss` file when you create a new project, which is included in your build configuration. To make sure it is used for global styling, confirm it is properly linked in your `angular.json`:

```json
{
  "projects": {
    "your-project-name": {
      "architect": {
        "build": {
          "styles": [
            "src/styles.scss"
          ]
        }
      }
    }
  }
}
```

With this setup, you will only have one global `styles.scss` file for your project, and no additional `.scss` or `.css` files will be generated for individual components or other entities.

### Example

Now, when you run:

```bash
ng generate component my-component
```

It will generate:

* `my-component.component.ts`
* `my-component.component.html`
* **No** `.scss` or `.css` file
* **No** `.spec.ts` test file

#### Conclusion

This configuration ensures that:

* **No test files** (`.spec.ts`) are generated for components, services, etc.
* **No style files** (CSS/SCSS) are generated for components, except for your global `styles.scss` file.

This is the cleanest setup to meet your needs—keeping only the global SCSS file while skipping unnecessary files for components, services, and other entities.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wisdom.gitbook.io/gyan/angular/skip-scss-and-test-files-in-angular-with-ng-generate.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
