<small id='6MMaf'></small><noframes id='6MMaf'>

      1. <tfoot id='6MMaf'></tfoot><legend id='6MMaf'><style id='6MMaf'><dir id='6MMaf'><q id='6MMaf'></q></dir></style></legend>
          <bdo id='6MMaf'></bdo><ul id='6MMaf'></ul>
      2. <i id='6MMaf'><tr id='6MMaf'><dt id='6MMaf'><q id='6MMaf'><span id='6MMaf'><b id='6MMaf'><form id='6MMaf'><ins id='6MMaf'></ins><ul id='6MMaf'></ul><sub id='6MMaf'></sub></form><legend id='6MMaf'></legend><bdo id='6MMaf'><pre id='6MMaf'><center id='6MMaf'></center></pre></bdo></b><th id='6MMaf'></th></span></q></dt></tr></i><div id='6MMaf'><tfoot id='6MMaf'></tfoot><dl id='6MMaf'><fieldset id='6MMaf'></fieldset></dl></div>

        Gulp 使用 @import 监视和编译更少的文件

        时间:2023-05-27
      3. <i id='lLseo'><tr id='lLseo'><dt id='lLseo'><q id='lLseo'><span id='lLseo'><b id='lLseo'><form id='lLseo'><ins id='lLseo'></ins><ul id='lLseo'></ul><sub id='lLseo'></sub></form><legend id='lLseo'></legend><bdo id='lLseo'><pre id='lLseo'><center id='lLseo'></center></pre></bdo></b><th id='lLseo'></th></span></q></dt></tr></i><div id='lLseo'><tfoot id='lLseo'></tfoot><dl id='lLseo'><fieldset id='lLseo'></fieldset></dl></div>

        1. <tfoot id='lLseo'></tfoot>

          <small id='lLseo'></small><noframes id='lLseo'>

          <legend id='lLseo'><style id='lLseo'><dir id='lLseo'><q id='lLseo'></q></dir></style></legend>

                <tbody id='lLseo'></tbody>

              • <bdo id='lLseo'></bdo><ul id='lLseo'></ul>
                1. 本文介绍了Gulp 使用 @import 监视和编译更少的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正试图用 gulp 来观察和编译一个 .less 项目 + livereload.我有一个使用 @import 的 style.less 文件.当我运行 gulp 任务时,它似乎不理解导入.当我修改主文件时,gulp 会编译文件并刷新浏览器,但如果我只修改导入,则更改将被忽略.

                  I'm trying to get my head around gulp to watch and compile a .less project + livereload. I have a style.less file which use @import. When i run the gulp task it doesn't seem to understand the imports. When I modify the main less file, gulp compiles the file and refresh the browser but if i modify only an import, the changes are ignored.

                  这是我的 gulpfile.js

                  Here is my gulpfile.js

                  var gulp = require('gulp');
                  var less = require('gulp-less');
                  var watch = require('gulp-watch');
                  var prefix = require('gulp-autoprefixer');
                  var plumber = require('gulp-plumber');
                  var livereload = require('gulp-livereload');
                  var path = require('path');
                  
                  gulp.task('default', function() {
                      return gulp.src('./style.less')
                          .pipe(watch())
                          .pipe(plumber())
                          .pipe(less({
                            paths: ['./', './overrides/']
                          }))
                          .pipe(prefix("last 8 version", "> 1%", "ie 8", "ie 7"), {cascade:true})
                          .pipe(gulp.dest('./'))
                          .pipe(livereload());
                  });
                  

                  我尝试在 gulp.src('./*.less') 中不指定主文件名,但是所有的 less 文件都是单独编译的.

                  I tried not specifying the main file name in gulp.src('./*.less') but then all of the less files are compiled indvidually.

                  谢谢

                  推荐答案

                  现在您正在打开单个 gulp.src 文件,并观看使用 gulp 打开文件后.下面将把 watch 和 src 分成两个任务,允许单独的 file 和 src 观看.

                  Right now you are opening the single gulp.src file, and watching After you open the file with gulp. The following will split the watching and src into two tasks, allowing for separate file and src watching.

                  var gulp = require('gulp');
                  var less = require('gulp-less');
                  var watch = require('gulp-watch');
                  var prefix = require('gulp-autoprefixer');
                  var plumber = require('gulp-plumber');
                  var livereload = require('gulp-livereload');
                  var path = require('path');
                  
                  gulp.task('less', function() {
                      return gulp.src('./style.less')  // only compile the entry file
                          .pipe(plumber())
                          .pipe(less({
                            paths: ['./', './overrides/']
                          }))
                          .pipe(prefix("last 8 version", "> 1%", "ie 8", "ie 7"), {cascade:true})
                          .pipe(gulp.dest('./'))
                          .pipe(livereload());
                  });
                  gulp.task('watch', function() {
                      gulp.watch('./*.less', ['less']);  // Watch all the .less files, then run the less task
                  });
                  
                  gulp.task('default', ['watch']); // Default will run the 'entry' watch task
                  

                  当使用 *.less 找到的任何文件被更改时,它将运行仅编译 src 文件的任务.@imports 应该被正确地包含",如果没有检查导入设置.

                  When Any of the files found with *.less are altered it will then run the task which will compile just the src file. The @imports should be 'included' correctly, if not check the import settings.

                  这篇关于Gulp 使用 @import 监视和编译更少的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在不使用 .pipe() 的情况下调用 gulp-notify 下一篇:如何在 docker 容器中使用 gulp 运行 livereload?

                  相关文章

                  最新文章

                  <small id='hndgw'></small><noframes id='hndgw'>

                  1. <i id='hndgw'><tr id='hndgw'><dt id='hndgw'><q id='hndgw'><span id='hndgw'><b id='hndgw'><form id='hndgw'><ins id='hndgw'></ins><ul id='hndgw'></ul><sub id='hndgw'></sub></form><legend id='hndgw'></legend><bdo id='hndgw'><pre id='hndgw'><center id='hndgw'></center></pre></bdo></b><th id='hndgw'></th></span></q></dt></tr></i><div id='hndgw'><tfoot id='hndgw'></tfoot><dl id='hndgw'><fieldset id='hndgw'></fieldset></dl></div>

                    • <bdo id='hndgw'></bdo><ul id='hndgw'></ul>
                      <tfoot id='hndgw'></tfoot>
                    1. <legend id='hndgw'><style id='hndgw'><dir id='hndgw'><q id='hndgw'></q></dir></style></legend>