Gulp-从节点 - sass迁移到sass for angular.js
我们有一个Angular.js项目,我们使用Gulp。
我正在尝试摆脱node-sass
,因为它已将其弃用sass
是Angular.js与Sass
Node版本兼容:15
我们在这里如何使用Node-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.compiler = require('sass');
然后用SASS应用程序不再
we have an Angular.JS project and we using Gulp.
I am trying to get out of node-sass
as its deprecated to dart sass
is angular.js compatible with sass
Node version : 15
here how we are using the node-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/'));
});
my tries to migrate
remove node-sass
and install sass
then replace the the compiler with sass
$.sass.compiler = require('sass');
app is not building anymore
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想如何使它
取代
以
这样的情况
I figure how to make it
replace
with
to be like this in my case
您还可以使用
poStrequirEtransForms
属性来配置gulp-sass
使用dart-sass
(在NPM)。更改:
当时
可以像往常一样使用插件属性
sass()
。$。sass()
。You can also use use the
postRequireTransforms
property to configuregulp-sass
to usedart-sass
(calledsass
in npm).Change:
to
Then can use the plugin property
sass()
as usual.$.sass()
.