Skip to content

Commit 0fca5f7

Browse files
Alanvikerman
Alan
authored and
vikerman
committed
fix(@schematics/angular): reintroduce .sass as a supported file extention
Sass Indented (.sass) is fully supported by the Sass team and we should still offer and support it. Fixes #13739
1 parent 9ad9c9d commit 0fca5f7

File tree

9 files changed

+15
-31
lines changed

9 files changed

+15
-31
lines changed

packages/schematics/angular/application/index.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import {
3131
url,
3232
} from '@angular-devkit/schematics';
3333
import { NodePackageInstallTask } from '@angular-devkit/schematics/tasks';
34-
import { styleToFileExtention } from '../component/index';
3534
import { Schema as ComponentOptions } from '../component/schema';
3635
import { Schema as E2eOptions } from '../e2e/schema';
3736
import {
@@ -187,8 +186,6 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
187186
});
188187
}
189188

190-
const styleExt = styleToFileExtention(options.style);
191-
192189
const project: WorkspaceProject = {
193190
root: projectRoot,
194191
sourceRoot: join(normalize(projectRoot), 'src'),
@@ -209,7 +206,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
209206
join(normalize(projectRoot), 'src', 'assets'),
210207
],
211208
styles: [
212-
`${projectRoot}src/styles.${styleExt}`,
209+
`${projectRoot}src/styles.${options.style}`,
213210
],
214211
scripts: [],
215212
es5BrowserSupport: true,
@@ -262,7 +259,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
262259
tsConfig: `${rootFilesRoot}tsconfig.spec.json`,
263260
karmaConfig: `${rootFilesRoot}karma.conf.js`,
264261
styles: [
265-
`${projectRoot}src/styles.${styleExt}`,
262+
`${projectRoot}src/styles.${options.style}`,
266263
],
267264
scripts: [],
268265
assets: [
@@ -351,8 +348,6 @@ export default function (options: ApplicationOptions): Rule {
351348
projectRoot: newProjectRoot ? `${newProjectRoot}/${options.name}-e2e` : 'e2e',
352349
};
353350

354-
const styleExt = styleToFileExtention(options.style);
355-
356351
return chain([
357352
addAppToWorkspaceFile(options, workspace),
358353
mergeWith(
@@ -363,7 +358,6 @@ export default function (options: ApplicationOptions): Rule {
363358
...options,
364359
'dot': '.',
365360
relativePathToWorkspaceRoot,
366-
styleExt,
367361
}),
368362
move(sourceRoot),
369363
])),
@@ -425,7 +419,6 @@ export default function (options: ApplicationOptions): Rule {
425419
...options as any, // tslint:disable-line:no-any
426420
selector: appRootSelector,
427421
...componentOptions,
428-
styleExt,
429422
}),
430423
move(sourceDir),
431424
]), MergeStrategy.Overwrite),

packages/schematics/angular/application/index_spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,13 +302,13 @@ describe('Application Schematic', () => {
302302
const prj = config.projects.foo;
303303
const buildOpt = prj.architect.build.options;
304304
expect(buildOpt.styles).toEqual([
305-
'src/styles.scss',
305+
'src/styles.sass',
306306
]);
307307
const testOpt = prj.architect.test.options;
308308
expect(testOpt.styles).toEqual([
309-
'src/styles.scss',
309+
'src/styles.sass',
310310
]);
311-
expect(tree.exists('src/styles.scss')).toBe(true);
311+
expect(tree.exists('src/styles.sass')).toBe(true);
312312
});
313313

314314
it('should set the relative tsconfig paths', () => {

packages/schematics/angular/application/other-files/app.component.ts.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { Component } from '@angular/core';
2828
`,<% } else { %>
2929
templateUrl: './app.component.html',<% } if(inlineStyle) { %>
3030
styles: []<% } else { %>
31-
styleUrls: ['./app.component.<%= styleExt %>']<% } %>
31+
styleUrls: ['./app.component.<%= style %>']<% } %>
3232
})
3333
export class AppComponent {
3434
title = '<%= name %>';

packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.component.ts.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Component, OnInit<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }
99
`,<% } else { %>
1010
templateUrl: './<%= dasherize(name) %>.component.html',<% } if(inlineStyle) { %>
1111
styles: []<% } else { %>
12-
styleUrls: ['./<%= dasherize(name) %>.component.<%= styleExt %>']<% } %><% if(!!viewEncapsulation) { %>,
12+
styleUrls: ['./<%= dasherize(name) %>.component.<%= style %>']<% } %><% if(!!viewEncapsulation) { %>,
1313
encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
1414
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
1515
})

packages/schematics/angular/component/index.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,12 @@ export default function (options: ComponentOptions): Rule {
154154

155155
const templateSource = apply(url('./files'), [
156156
options.skipTests ? filter(path => !path.endsWith('.spec.ts.template')) : noop(),
157-
options.inlineStyle ? filter(path => !path.endsWith('.__styleExt__.template')) : noop(),
157+
options.inlineStyle ? filter(path => !path.endsWith('.__style__.template')) : noop(),
158158
options.inlineTemplate ? filter(path => !path.endsWith('.html.template')) : noop(),
159159
applyTemplates({
160160
...strings,
161161
'if-flat': (s: string) => options.flat ? '' : s,
162162
...options,
163-
styleExt: styleToFileExtention(options.style),
164163
}),
165164
move(parsedPath.path),
166165
]);
@@ -172,12 +171,3 @@ export default function (options: ComponentOptions): Rule {
172171
]);
173172
};
174173
}
175-
176-
export function styleToFileExtention(style: Style | undefined): string {
177-
switch (style) {
178-
case Style.Sass:
179-
return 'scss';
180-
default:
181-
return style || 'css';
182-
}
183-
}

packages/schematics/angular/component/index_spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ describe('Component Schematic', () => {
253253
const options = { ...defaultOptions, style: Style.Sass };
254254
const tree = schematicRunner.runSchematic('component', options, appTree);
255255
const content = tree.readContent('/projects/bar/src/app/foo/foo.component.ts');
256-
expect(content).toMatch(/styleUrls: \['.\/foo.component.scss/);
257-
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.scss');
256+
expect(content).toMatch(/styleUrls: \['.\/foo.component.sass/);
257+
expect(tree.files).toContain('/projects/bar/src/app/foo/foo.component.sass');
258258
expect(tree.files).not.toContain('/projects/bar/src/app/foo/foo.component.css');
259259
});
260260

packages/schematics/angular/ng-new/schema.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,11 @@
125125
"message": "Which stylesheet format would you like to use?",
126126
"type": "list",
127127
"items": [
128-
{ "value": "css", "label": "CSS (.css )" },
129-
{ "value": "sass", "label": "Sass (.scss) [ http://sass-lang.com ]" },
130-
{ "value": "less", "label": "Less (.less) [ http://lesscss.org ]" },
131-
{ "value": "styl", "label": "Stylus (.styl) [ http://stylus-lang.com ]" }
128+
{ "value": "css", "label": "CSS" },
129+
{ "value": "scss", "label": "SCSS [ http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax ]" },
130+
{ "value": "sass", "label": "Sass [ http://sass-lang.com/documentation/file.INDENTED_SYNTAX.html ]" },
131+
{ "value": "less", "label": "Less [ http://lesscss.org ]" },
132+
{ "value": "styl", "label": "Stylus [ http://stylus-lang.com ] " }
132133
]
133134
}
134135
},

0 commit comments

Comments
 (0)