我们有一个Angular.JS项目,我们使用Gulp。
我正试图摆脱node-sass,因为它被推荐为dart sass
angular.js与sass兼容吗?
节点版本: 15
这里我们是如何使用节点-sass的
'use strict';
var gulp = require('gulp');
var paths = gulp.paths;
var $ = require('gulp-load-plugins')();
// TODO: node-sass is deprecated; replace with
// dart-sass (https://sass-lang.com/dart-sass)
$.sass.compiler = require('node-sass');
gulp.task('styles', function () {
var injectFiles = gulp.src([
paths.src + '/{app,components}/**/*.scss',
'!' + paths.src + '/app/index.scss',
'!' + paths.src + '/app/vendor.scss'
], { read: false });
var injectOptions = {
transform: function(filePath) {
filePath = filePath.replace(paths.src + '/app/', '');
filePath = filePath.replace(paths.src + '/components/', '../components/');
return '@import \'' + filePath + '\';';
},
starttag: '// injector',
endtag: '// endinjector',
addRootSlash: false
};
// "Enables you to work on a subset of the original files by filtering them
// using glob patterns. When you're done and want all the original files back,
// you just use the restore stream"
var indexFilter = $.filter(paths.src + '/app/index.scss', {restore: true});
return gulp.src([
paths.src + '/app/index.scss', // A template, empty except for the injection target
paths.src + '/app/vendor.scss' // Currently not used
], {allowEmpty: true})
.pipe(indexFilter)
.pipe($.inject(injectFiles, injectOptions)) // injects the @import's to all app and component scss
.pipe(indexFilter.restore)
.pipe($.sass().on('error', $.sass.logError)) // compiles index.scss (and vendor.scss if existent)
.pipe($.autoprefixer()
.on('error', function handleError(err) {
console.error(err.toString());
this.emit('end');
})
)
.pipe(gulp.dest(paths.tmp + '/serve/app/'));
});我试图迁移
删除node-sass并安装sass,然后用sass替换编译器
$.sass.compiler = require('sass');应用程序不再构建了
发布于 2022-06-23 20:02:21
我想怎么做
替换
var sass = require('gulp-sass'));
var compiler = require('sass');
sass.compiler = compiler;使用
var sass = require('gulp-sass')(require('sass'));在我的情况下是这样的
....
.pipe(sass().on('error', sass.logError))
....https://stackoverflow.com/questions/72732918
复制相似问题