Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After add @ngrx/schematics to ng6 project, cli generate component with css instead of scss #1036

Closed
kklimczak opened this issue May 9, 2018 · 14 comments · Fixed by #2507
Closed

Comments

@kklimczak
Copy link
Contributor

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

When we add schematics from ngrx and change default schematics collection, cli stop generate components with scss files.
When we revert the default collection, cli start again generate components with scss files.

Of course, we set

"schematics": {
  "@schematics/angular:component": {
    "styleext": "scss"
  }
}

in angular.json file, also set with @ngrx/schematics/angular:component.

Expected behavior:

When we use ngrx schematics as a default collection, cli should still generate scss, when it set.

Minimal reproduction of the problem with instructions:

  1. Generate project with @angular/cli@6.0.0
  2. Follow this instruction to install ngrx with schematics and set it as default schematics collection.
  3. Set SCSS as default css preprocessor in angular.json file using schematics:
"schematics": {
  "@schematics/angular:component": {
    "styleext": "scss"
  }
}

Optional try with @ngrx/schematics/angular:component instead of @schematics/angular:component
4. Generate component via CLI.

Version of affected browser(s),operating system(s), npm, node and ngrx:

node: 8.11.1
npm: 6.0.0
dependencies:

  "dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "^5.2.0",
    "@ngrx/entity": "^5.2.0",
    "@ngrx/store": "^5.2.0",
    "@ngrx/store-devtools": "^5.2.0",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "rxjs-compat": "^6.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.0",
    "@angular-devkit/schematics": "^0.6.0",
    "@angular/cli": "^6.0.0",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "^6.0.0",
    "@ngrx/schematics": "^5.2.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }

Other information:

angular.json file:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ls-admin-web": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "styleext": "scss"
        }
      },
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ls-admin-web",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "ls-admin-web:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "ls-admin-web:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "ls-admin-web:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "styles.scss"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "ls-admin-web-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "ls-admin-web:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "ls-admin-web",
  "cli": {
    "defaultCollection": "@ngrx/schematics"
  }
}
@timdeschryver
Copy link
Member

Fyi, in the meantime I believe you can pass the styleext via de cli via --styleext scss.

@kklimczak
Copy link
Contributor Author

Yeah, of cource, we know this solution but it's a workaround. Before we don't additional param for this.
I know it is a small thing but very helpful.

@timdeschryver
Copy link
Member

timdeschryver commented May 9, 2018

Yea you're right, just said it in case someone has the same problem and doesn't know it is possible to pass it as an argument.

@brandonroberts
Copy link
Member

brandonroberts commented May 9, 2018

This seems like an Angular CLI issue, since we're just extending those schematics. And you should verify this issue against the latest NgRx betas.

@alexanderwende
Copy link

I can verify the reported behavior with latest @ngrx/schematics. Still generates css files instead of scss, even though styleext is set to scss.

package.json with used versions:

{
  "name": "ng6-ngrx",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.0",
    "@angular/cdk": "^6.0.1",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "@ngrx/effects": "^6.0.0-beta.2",
    "@ngrx/entity": "^6.0.0-beta.2",
    "@ngrx/router-store": "^6.0.0-beta.2",
    "@ngrx/store": "^6.0.0-beta.2",
    "@ngrx/store-devtools": "^6.0.0-beta.2",
    "core-js": "^2.5.4",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.1",
    "@angular/cli": "~6.0.1",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "^6.0.0",
    "@ngrx/schematics": "^6.0.0-beta.2",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "~2.7.2"
  }
}

But thanks for posting the workaround! :)

@brandonroberts
Copy link
Member

If you set the default styleext for @ngrx/schematics:component does it work?

@timdeschryver
Copy link
Member

@brandonroberts when putting the configurations inside @ngrx/schematics:component it does work.

@kklimczak
Copy link
Contributor Author

Could you mention this information in the schematics documentation?

@brandonroberts
Copy link
Member

I'm going to verify with the CLI team that its supposed to work that way. If so, then yes we'll update the docs.

@brandonroberts
Copy link
Member

The CLI team confirmed that you should set the defaults for @ngrx/schematics:component in your angular.json. @kklimczak would you like to put in a PR for this?

@kklimczak
Copy link
Contributor Author

I created PR for this.

@davidtlee
Copy link

I just noticed a similar bug. After following the same instructions above, it works for generating components, but not for containers. In other words:

  • ng g container <name> generates a .css file
  • ng g component <name> generates a .scss file
  • ng g container <name> --styleext scss generates a .scss file

@olefrank
Copy link

olefrank commented Jan 31, 2019

I can't get this to work... Any news on this?

Am I doing it wrong in angular.json?

{
...
 "defaultProject": "xxx-xxx",
  "cli": {
    "defaultCollection": "@ngrx/schematics"
  },
  "schematics": {
    "@ngrx/schematics/angular:component": {
      "styleext": "scss"
    },
    "@schematics/angular:component": {
      "styleext": "scss"
    }
}

@BlindDespair
Copy link

BlindDespair commented Apr 30, 2020

This is still not working with Angular 9 and ngrx 9.

"schematics": {
        "@ngrx/schematics:component": {
          "style": "scss"
        }
},

Anything changed?
This works though:

"schematics": {
        "@ngrx/schematics:component": {
          "style": "scss"
        },
        "@schematics/angular:component": {
          "style": "scss"
        }
},

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants