我想在我的项目中使用SASS。我打开此链接并按照所有命令。我创建一个项目并设置SASS。 http://learn.ionicframework.com/formulas/working-with-sass/如何在离子框架中使用SASS?
我得到这个目录结构
scss
|
|—>ionic.app.scss
www
|
|->css
|
|——>ionic.app.css
在的index.html文件我style
标签进口ionic.app.css。所以无论我改变ionic.app.scss文件它来ionic.app.css文件并反映在视图中。
如果我index.html中添加一些元素,比如我加入<ion-content>
段落标记:
<ion-pane>
<ion-header-bar class="bar-stable">
<h1 class="title">Ionic Blank Starter</h1>
</ion-header-bar>
<ion-content>
<p id=“addp”>Testparagraph</p>
</ion-content>
</ion-pane>
和加入这个
#addp{
background-color:yellow;
}
ionic.app.scss,它添加在ionic.app.css并反映在视图中。
现在我试着去做。我想添加自己的文件“application.scss”在sass文件夹中应创建另一个文件“application.css”在css文件夹中。所以无论我在“application.scss”中编码,它都在“application.css”文件中,它反映在视图中。我输入“application.css” in index.html file。
我在哪写这段代码让我生成这个文件并观看我的“application.scss”文件。
当我运行离子服务器,我改变任何东西在“ionic.app.scss”文件它反映在同一时间。我需要做的与“application.scss”相同。如果我更改“application.scss”它会反映我的观点。
这是我gulpfile.js
var gulp = require('gulp');
var gutil = require('gulp-util');
var bower = require('bower');
var concat = require('gulp-concat');
var sass = require('gulp-sass');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sh = require('shelljs');
var paths = {
sass: ['./scss/**/*.scss']
};
gulp.task('default', ['sass']);
gulp.task('sass', function(done) {
gulp.src('./scss/ionic.app.scss')
.pipe(sass({
errLogToConsole: true
}))
.pipe(gulp.dest('./www/css/'))
.pipe(minifyCss({
keepSpecialComments: 0
}))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest('./www/css/'))
.on('end', done);
});
gulp.task('watch', function() {
gulp.watch(paths.sass, ['sass']);
});
gulp.task('install', ['git-check'], function() {
return bower.commands.install()
.on('log', function(data) {
gutil.log('bower', gutil.colors.cyan(data.id), data.message);
});
});
gulp.task('git-check', function(done) {
if (!sh.which('git')) {
console.log(
' ' + gutil.colors.red('Git is not installed.'),
'\n Git, the version control system, is required to download Ionic.',
'\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.',
'\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.'
);
process.exit(1);
}
done();
});
你因此未得到我的问题,我需要添加其他文件。如果我没有兴趣与_variables.scss或ionic.app.scss file.I工作要在我的SASS文件夹中添加此application.scss,这应该生成另一个css文件。我将导入index.html –
上的css文件。但是,当我在sass文件夹中添加application.scss时,gulp进程不会观察我的文件。未反映在html视图 –
上,您必须更改行'gulp。 src('./scss/ionic.app.scss')'到'gulp.src('./scss/ * .scss')',选择任何.scss文件 – sameera207