有没有办法用@imports编译更少的文件,并用Gulp连接它们,所有这些文件都在同一个流中?
我正在我的gulpfile.js中triyng这个:有没有办法用@imports编译更少的文件,并用Gulp连接它们,所有这些文件都在同一个流中?,gulp,gulp-less,gulp-sourcemaps,gulp-concat,Gulp,Gulp Less,Gulp Sourcemaps,Gulp Concat,我正在我的gulpfile.js中triyng这个: gulp.task('buildStyles', function() { return gulp.src([ './styles/less/main.less', './styles/less/widgets/widgets.less', './styles/less/pages/pages.less', './styles/less/themes/default.less', './style
gulp.task('buildStyles', function() {
return gulp.src([
'./styles/less/main.less',
'./styles/less/widgets/widgets.less',
'./styles/less/pages/pages.less',
'./styles/less/themes/default.less',
'./styles/less/rtl/rtl.less'
])
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(less())
.pipe(concat('allmin.css'))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('./dest'));
});
但我总是收到这样的信息:
$ gulp buildStyles
[18:46:31] Using gulpfile /Library/WebServer/Documents/qjt2015/trunk/gulpfile.js
[18:46:31] Starting 'buildStyles'...
gulp-sourcemap-write: source file not found:/Library/WebServer/Documents/qjt2015/trunk/styles/less/support-tickets.less
gulp-sourcemap-write: source file not found:/Library/WebServer/Documents/qjt2015/trunk/styles/less/comments.less
gulp-sourcemap-write: source file not found:/Library/WebServer/Documents/qjt2015/trunk/styles/less/article-comments.less
gulp-sourcemap-write: source file not found:/Library/WebServer/Documents/qjt2015/trunk/styles/less/threads.less
gulp-sourcemap-write: source file not found:/Library/WebServer/Documents/qjt2015/trunk/styles/less/chat.less
我在我所有的less文件中都使用了@imports,这些引用是那些在消息中显示为未找到的引用。例如,my widgets.less文件如下所示:
// ### Bootstrap's variables andmixins
@import "../../../bower_components/bootstrap/less/variables.less";
@import "../../../bower_components/bootstrap/less/mixins.less";
@import '../variables.less';
@import '../mixins.less';
@import './support-tickets.less';
@import './comments.less';
@import './article-comments.less';
@import './threads.less';
@import './chat.less';
我错过什么了吗?
提前,谢谢你的帮助 您只需为gulp less指定选项,告诉它应该从哪里开始搜索使用@import指令指定的文件 例如,在
widgets.less
中,它试图找到
支持票证。更少
comments.less
article comments.less
- 等等
在
中(请参阅您发布的错误消息),但我认为应该在Library/WebServer/Documents/qjt2015/trunk/styles/less/
中(相对于Library/WebServer/Documents/qjt2015/trunk/styles/less/widgets/
文件)widgets.less
gulp.task('buildStyles', function() {
return gulp.src([
// ...
])
// ... other gulp tasks here
.pipe(less({
paths: [
'/Library/WebServer/Documents/qjt2015/trunk/styles/less/',
'/Library/WebServer/Documents/qjt2015/trunk/styles/less/widgets/',
'/Library/WebServer/Documents/qjt2015/trunk/styles/less/pages/',
// add additional paths here for less to find imports in
// less will tell you which import files it can't find, so simply tell it where to find them.
]
))
.pipe(concat('allmin.css'))
// ...
});