diff --git a/addon/ng2/blueprints/component/files/__path__/__name__.component.ts b/addon/ng2/blueprints/component/files/__path__/__name__.component.ts index 38db38db508e..ddef63fead2a 100644 --- a/addon/ng2/blueprints/component/files/__path__/__name__.component.ts +++ b/addon/ng2/blueprints/component/files/__path__/__name__.component.ts @@ -10,7 +10,7 @@ import { Component, OnInit } from '@angular/core'; `,<% } else { %> templateUrl: '<%= dasherizedModuleName %>.component.html',<% } if(inlineStyle) { %> styles: []<% } else { %> - styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>']<% } %> + styleUrls: ['<%= dasherizedModuleName %>.component.css']<% } %> }) export class <%= classifiedModuleName %>Component implements OnInit { diff --git a/addon/ng2/blueprints/component/index.js b/addon/ng2/blueprints/component/index.js index 03342908f36c..3c1f171ecabe 100644 --- a/addon/ng2/blueprints/component/index.js +++ b/addon/ng2/blueprints/component/index.js @@ -39,8 +39,12 @@ module.exports = { }, locals: function (options) { - //TODO: pull value from config this.styleExt = 'css'; + if (this.project.ngConfig && + this.project.ngConfig.defaults && + this.project.ngConfig.defaults.styleExt) { + this.styleExt = this.project.ngConfig.defaults.styleExt; + } return { dynamicPath: this.dynamicPath.dir.replace(this.dynamicPath.appRoot, ''), @@ -48,7 +52,6 @@ module.exports = { inlineTemplate: options.inlineTemplate, inlineStyle: options.inlineStyle, route: options.route, - styleExt: this.styleExt, isLazyRoute: !!options.isLazyRoute, isAppComponent: !!options.isAppComponent, selector: this.selector @@ -94,7 +97,7 @@ module.exports = { return dir; }, __styleext__: () => { - return options.locals.styleExt; + return this.styleExt; } }; }, diff --git a/addon/ng2/blueprints/ng2/files/__path__/app/__name__.component.ts b/addon/ng2/blueprints/ng2/files/__path__/app/__name__.component.ts index 7ace455b7781..40303df298e4 100644 --- a/addon/ng2/blueprints/ng2/files/__path__/app/__name__.component.ts +++ b/addon/ng2/blueprints/ng2/files/__path__/app/__name__.component.ts @@ -9,7 +9,7 @@ import { Component } from '@angular/core'; `, styles: []<% } else { %>templateUrl: '<%= htmlComponentName %>.component.html', - styleUrls: ['<%= dasherizedModuleName %>.component.<%= styleExt %>']<% } %> + styleUrls: ['<%= dasherizedModuleName %>.component.css']<% } %> }) export class <%= jsComponentName %>AppComponent { title = '<%= htmlComponentName %> works!'; diff --git a/addon/ng2/blueprints/ng2/files/angular-cli.json b/addon/ng2/blueprints/ng2/files/angular-cli.json index 29c6e2b70838..167af80f6014 100644 --- a/addon/ng2/blueprints/ng2/files/angular-cli.json +++ b/addon/ng2/blueprints/ng2/files/angular-cli.json @@ -24,6 +24,7 @@ }, "defaults": { "prefix": "<%= prefix %>", - "sourceDir": "<%= sourceDir %>" + "sourceDir": "<%= sourceDir %>", + "styleExt": "css" } } diff --git a/addon/ng2/blueprints/ng2/index.js b/addon/ng2/blueprints/ng2/index.js index 4677ba041473..881c36cbec03 100644 --- a/addon/ng2/blueprints/ng2/index.js +++ b/addon/ng2/blueprints/ng2/index.js @@ -8,6 +8,7 @@ module.exports = { availableOptions: [ { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, + { name: 'style', type: String, default: 'css' }, { name: 'mobile', type: Boolean, default: false } ], @@ -18,8 +19,7 @@ module.exports = { }, locals: function(options) { - //TODO: pull value from config - this.styleExt = 'css'; + this.styleExt = options.style; this.version = require(path.resolve(__dirname, '..', '..', '..', '..', 'package.json')).version; // Join with / not path.sep as reference to typings require forward slashes. @@ -32,10 +32,10 @@ module.exports = { htmlComponentName: stringUtils.dasherize(options.entity.name), jsComponentName: stringUtils.classify(options.entity.name), fullAppName: fullAppName, - styleExt: this.styleExt, version: this.version, sourceDir: options.sourceDir, prefix: options.prefix, + styleExt: this.styleExt, refToTypings: refToTypings, isMobile: options.mobile }; @@ -48,7 +48,7 @@ module.exports = { return options.locals.sourceDir; }, __styleext__: () => { - return options.locals.styleExt; + return this.styleExt; } }; } diff --git a/addon/ng2/commands/init.js b/addon/ng2/commands/init.js index 2207712ba248..71222d146b2d 100644 --- a/addon/ng2/commands/init.js +++ b/addon/ng2/commands/init.js @@ -21,6 +21,7 @@ module.exports = Command.extend({ { name: 'skip-bower', type: Boolean, default: true, aliases: ['sb'] }, { name: 'name', type: String, default: '', aliases: ['n'] }, { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'mobile', type: Boolean, default: false } ], @@ -90,6 +91,7 @@ module.exports = Command.extend({ targetFiles: rawArgs || '', rawArgs: rawArgs.toString(), sourceDir: commandOptions.sourceDir, + style: commandOptions.style, prefix: commandOptions.prefix, mobile: commandOptions.mobile }; diff --git a/addon/ng2/commands/new.ts b/addon/ng2/commands/new.ts index e5b226bb30cf..253778c1e7d8 100644 --- a/addon/ng2/commands/new.ts +++ b/addon/ng2/commands/new.ts @@ -21,6 +21,7 @@ const NewCommand = Command.extend({ { name: 'skip-git', type: Boolean, default: false, aliases: ['sg'] }, { name: 'directory', type: String, aliases: ['dir'] }, { name: 'source-dir', type: String, default: 'src', aliases: ['sd'] }, + { name: 'style', type: String, default: 'css' }, { name: 'prefix', type: String, default: 'app', aliases: ['p'] }, { name: 'mobile', type: Boolean, default: false } ], diff --git a/lib/config/schema.json b/lib/config/schema.json index feab2c84326a..467844abff2a 100644 --- a/lib/config/schema.json +++ b/lib/config/schema.json @@ -86,6 +86,9 @@ }, "sourceDir": { "type": "string" + }, + "styleExt": { + "type": "string" } }, "additionalProperties": false