ialexivy / vscode-angular2-files

vscode extension generating angular files with angular cli
MIT License
61 stars 36 forks source link

default to scss not detected #78

Open portalpap opened 1 year ago

portalpap commented 1 year ago

When I generate a component it always defaults to CSS rather than SCSS unless I use the -o tag select -styleext then type scss. Is there a flag that quickly makes it scss or a way to set those overrides in the -o to be the default. my angular.json is defaulted to scss
"schematics": { "@schematics/angular:component": { "style": "scss" } }, Any help from anyone is greatly appreciated! tia

crystalYY commented 1 year ago

I have the same question when I use the angular v16.0.0 but it is good when I use ths angular v8.2.14

albancho commented 1 year ago

Same here. default style is not detected on angular 14 and angular 16 (plugin generates a css file), whereas it works when using ng g c foo (cli generates an scss file), Using this config in angular.json:

  "projects": {
    "my-project": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss"
        }
      },

As stated in an other issue, the plugin is looking for "styleext", instead of "style", that may be related. I tried adding a fake "styleext" in the schematics, I get a warning "Property styleext is not allowed", and plugin still doesn't uses it.

crystalYY commented 1 year ago

您好,您的邮件我已收到,会尽快回复!樊

JoseManuelFV commented 1 year ago

The problem does not lie in whether you need to take styleext or style.

The problem is this line: https://github.com/ivalexa/vscode-angular2-files/blob/b62c6f335b14c0ae6099cac03b367bb42fef9079/src/configuration-manager.ts#L46

Needs the defaultProject setting that was removed in angular 14.0 You need add in your angular.json the setting defaultProject and add styleext. Here is an example:

  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "defaultProject" : "testProject",
  "projects": {
    "testProject": {
      "schematics": {
        "@schematics/angular:component": {
          "style": "scss",
          "styleext": "scss"
        }
      },
     }
   }

Another possible solution would be to take the scematic out of projects and make it a "global" configuration. Here is an example:

  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "schematics": {
    "@schematics/angular:component": {
      "style": "scss",
      "styleext": "scss"
     }
   },
  "projects": {
   }
crystalYY commented 1 year ago

您好,您的邮件我已收到,会尽快回复!樊

JoseManuelFV commented 1 year ago

I created one pull request for update https://github.com/ivalexa/vscode-angular2-files/pull/79 And i added release into my fork https://github.com/JoseManuelFV/vscode-angular2-files/releases/tag/1.6.5

To install just delete the previous version and drag the file to the add-ons tab.

albancho commented 1 year ago

Thank you very much @JoseManuelFV, both your suggestions work. The first one (defaultProject) triggers a "deprecated" rule on the angular.json, but the second one (global schematics) is totally fine.

alvarosinmarca commented 1 year ago

@JoseManuelFV Thx!!!!!!!!!!!