Skip to content

fix(@schematics/angular): set config when using sass as preprocessor #13552

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

Merged
merged 1 commit into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/schematics/angular/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
});
}

const styleExt = styleToFileExtention(options.style);

const project: WorkspaceProject = {
root: projectRoot,
sourceRoot: join(normalize(projectRoot), 'src'),
Expand All @@ -205,7 +207,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
join(normalize(projectRoot), 'src', 'assets'),
],
styles: [
`${projectRoot}src/styles.${options.style}`,
`${projectRoot}src/styles.${styleExt}`,
],
scripts: [],
es5BrowserSupport: true,
Expand Down Expand Up @@ -258,7 +260,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, workspace: Workspace
tsConfig: `${rootFilesRoot}tsconfig.spec.json`,
karmaConfig: `${rootFilesRoot}karma.conf.js`,
styles: [
`${projectRoot}src/styles.${options.style}`,
`${projectRoot}src/styles.${styleExt}`,
],
scripts: [],
assets: [
Expand Down
18 changes: 17 additions & 1 deletion packages/schematics/angular/application/index_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SchematicTestRunner, UnitTestTree } from '@angular-devkit/schematics/te
import { latestVersions } from '../utility/latest-versions';
import { getFileContent } from '../utility/test';
import { Schema as WorkspaceOptions } from '../workspace/schema';
import { Schema as ApplicationOptions } from './schema';
import { Schema as ApplicationOptions, Style } from './schema';

// tslint:disable:max-line-length
describe('Application Schematic', () => {
Expand Down Expand Up @@ -275,6 +275,22 @@ describe('Application Schematic', () => {
]);
});

it('should set values in angular.json correctly when using a style preprocessor', () => {
const options = { ...defaultOptions, projectRoot: '', style: Style.Sass };
const tree = schematicRunner.runSchematic('application', options, workspaceTree);
const config = JSON.parse(tree.readContent('/angular.json'));
const prj = config.projects.foo;
const buildOpt = prj.architect.build.options;
expect(buildOpt.styles).toEqual([
'src/styles.scss',
]);
const testOpt = prj.architect.test.options;
expect(testOpt.styles).toEqual([
'src/styles.scss',
]);
expect(tree.exists('src/styles.scss')).toBe(true);
});

it('should set the relative tsconfig paths', () => {
const options = { ...defaultOptions, projectRoot: '' };

Expand Down