How configure inline style and html template in `angular.json`?
Asked Answered
D

1

5

It look like all tutorials show how config it in the old angular.cli.json format.

"defaults": {
  "styleExt": "css",
  "component": {
    "inlineStyle":true,
    "inlineTemplate":true
  }
}

but not in the angular.json format. and that arises the error Workspace needs to be loaded before it is used

So how I can change the configuration of an existing project to generate component with an inline template and CSS/SCSS

Thanks.

Defy answered 3/8, 2018 at 11:0 Comment(0)
D
10

After researching the angular CLI command and generate a new project with that setting I come with that solution :

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "project-name": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {
        "@schematics/angular:component": {
          "inlineTemplate": true,
          "inlineStyle": true,
          "styleext": "scss"
        }
      }, ....
}
Defy answered 3/8, 2018 at 11:3 Comment(2)
Do you know the equivalent for Nx ?Absa
@Absa I just figured this one out. In nx.json, under "generators" you can put something like this: ` "@nx/angular:component": { "style": "css", "inlineStyle": true, "inlineTemplate": true, "viewEncapsulation": "None", "standalone": true, "changeDetection": "OnPush", "displayBlock": true } ` The options are coming from nx.dev/nx-api/angular/generators/component Sorry but I can't get this thing to format properly.Ligneous

© 2022 - 2024 — McMap. All rights reserved.