From b2cb5cf2279692c98c76bf0fa5510a4459cc381b Mon Sep 17 00:00:00 2001 From: Diego Netto Date: Sun, 7 Sep 2014 18:21:20 -0500 Subject: [PATCH] fix(sass): Ensure CSS or SCSS files are properly created. Change wiredep config. Closes #99 --- app/index.js | 21 +++++++++++++-------- templates/common/Gruntfile.js | 3 --- templates/styles/main.css | 9 +-------- templates/styles/main.sass | 7 ------- templates/styles/main.scss | 1 + 5 files changed, 15 insertions(+), 26 deletions(-) delete mode 100644 templates/styles/main.sass create mode 100644 templates/styles/main.scss diff --git a/app/index.js b/app/index.js index dea3c85..df36776 100644 --- a/app/index.js +++ b/app/index.js @@ -135,16 +135,21 @@ IonicGenerator.prototype.createIndexHtml = function createIndexHtml() { this.write(path.join(this.appPath, 'index.html'), this.indexFile); }; -IonicGenerator.prototype.copyStyles = function copyStyles() { - var sass = this.compass; - var mainFile = 'main.' + (sass ? 'sass' : 'css'); - +IonicGenerator.prototype.ensureStyles = function ensureStyles() { // Only create a main style file if the starter template didn't // have any styles. In the case it does, the starter should - // supply both main.css and main.sass files. - if (_.isEmpty(this.expand('app/styles/main.*'))) { - this.copy('styles/' + mainFile, 'app/styles/' + mainFile); - } + // supply both main.css and main.scss files, one of which + // will be deleted + var done = this.async(); + var unusedFile = 'main.' + (this.compass ? 'css' : 'scss'); + fs.unlink(path.resolve('app/styles', unusedFile), function (err) { + if (_.isEmpty(this.expand('app/styles/main.*'))) { + var cssFile = 'main.' + (this.compass ? 'scss' : 'css'); + this.copy('styles/' + cssFile, 'app/styles/' + cssFile); + } + done(); + }.bind(this)); + }; IonicGenerator.prototype.packageFiles = function packageFiles() { diff --git a/templates/common/Gruntfile.js b/templates/common/Gruntfile.js index fd22962..5d3b848 100644 --- a/templates/common/Gruntfile.js +++ b/templates/common/Gruntfile.js @@ -173,9 +173,6 @@ module.exports = function (grunt) { // Automatically inject Bower components into the app wiredep: { - options: { - cwd: '<%%= yeoman.app %>' - }, app: { src: ['<%%= yeoman.app %>/index.html'], ignorePath: /\.\.\// diff --git a/templates/styles/main.css b/templates/styles/main.css index d2783e4..a5a69e6 100644 --- a/templates/styles/main.css +++ b/templates/styles/main.css @@ -1,8 +1 @@ -/* Your app's CSS, go crazy, make it your own */ - -.ionic-logo { - display: block; - margin: 15px auto; - width: 96px; - height: 96px; -} +/* Your application styles go here */ diff --git a/templates/styles/main.sass b/templates/styles/main.sass deleted file mode 100644 index cbccc8a..0000000 --- a/templates/styles/main.sass +++ /dev/null @@ -1,7 +0,0 @@ -/* Your app's SASS, go crazy, make it your own */ - -.ionic-logo - display: block - margin: 15px auto - width: 96px - height: 96px \ No newline at end of file diff --git a/templates/styles/main.scss b/templates/styles/main.scss new file mode 100644 index 0000000..9719141 --- /dev/null +++ b/templates/styles/main.scss @@ -0,0 +1 @@ +// Your application styles go here