gpt4 book ai didi

css - Ionic Framework - Sass 未编译

转载 作者:技术小花猫 更新时间:2023-10-29 11:00:52 26 4
gpt4 key购买 nike

我有一个 Ionic V1 应用程序,我做了 ionic setup sass

我在 ionic.config.jsonwatchPatterns 中添加了 scss。 Gulp 检测到文件更改但不会将 scss 编译到 css 中。尝试了很多东西。

我做了两次ionic setup sass。似乎 sass 只有在我执行 ionic setup sass 后才会编译成 css。

这是 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())
.on('error', sass.logError)
.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();
});

最佳答案

我更新到 IONIC 2 几天后遇到了同样的问题。只需将这两行添加到您的 gulpfile.js:

gulp.task('serve:before', ['default','watch']);
gulp.task('run:before', ['default']);

它对我有用。

关于css - Ionic Framework - Sass 未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38973466/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com