我们有一个Angular.JS项目,我们使用Gulp。
我正在尝试退出node-sass
,因为它已被dart sass
取代
angular.js与sass兼容
节点版本:15
下面是我们如何使用节点会话
'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');
应用程序不再生成
1条答案
按热度按时间i7uq4tfw1#
我知道怎么做
取代了
与
在我的情况下是这样的