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

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

      1. Gulp-sass 无法编译 scss 文件

        时间:2023-05-28

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

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

              <legend id='Q1MGw'><style id='Q1MGw'><dir id='Q1MGw'><q id='Q1MGw'></q></dir></style></legend>
              • <bdo id='Q1MGw'></bdo><ul id='Q1MGw'></ul>
              • <tfoot id='Q1MGw'></tfoot>

                  本文介绍了Gulp-sass 无法编译 scss 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用 Gulp 将我的 sass 编译成 css.一个简单的任务编译 _/sass 目录中的 style.scss 文件,并将输出保存到项目的根目录中.style.scss 仅用于导入 _/sass 目录下的其他文件.

                  I'm using Gulp to compile my sass into css. A simple task compiles the style.scss file in the _/sass directory and saves the output into the root of the project. style.scss is used merely to import other files in the _/sass directory.

                  当我从命令行 ($ gulp) 运行默认任务时,我收到一个 sass 无法编译的错误.它全部包含在下面.我已从包含的文件中删除所有内容并再次运行该任务.我仍然收到相同的错误(我在网上阅读的内容表明这可能会测试编码问题.我不完全了解编码以及这可能会如何破坏我的场景).

                  When I run the default task from the command line ($ gulp) I get an error that the sass can't compile. It is included below in full. I have removed all content from the included files and run the task again. I still receive the same error (something I read online suggested this might test for an encoding issue. I don't fully understand encoding and how that might break things in my scenario).

                  我还从命令行 $ sass _/sass/style.scss style.css 运行,它与包含文件中的内容完美配合.这表明 gulp sass 插件本身存在问题.

                  I've also run from the command line $ sass _/sass/style.scss style.css which works perfectly with content in the included files. This suggests to me a problem with the gulp sass plugin itself.

                  来自 gulpfile.js 的相关片段:

                  The relevant snippets from gulpfile.js:

                  var gulp = require('gulp');
                  var sass = require('gulp-sass');
                  
                  // Compile sass files
                  gulp.task('sass', function () {
                      gulp.src('./_/sass/style.scss')
                          .pipe(sass())
                          .pipe(gulp.dest('./'));
                  });
                  
                  // The default task (called when you run `gulp`)
                  gulp.task('default', function() {
                    gulp.run('sass');
                  
                    // Watch files and run tasks if they change
                  
                    gulp.watch(['./_/sass/style.scss'], function() {
                      gulp.run('sass');
                    })
                  });
                  

                  style.scss的全部内容:

                  The full contents of style.scss:

                  /* RESET */
                  @import '_/sass/reset';
                  /* TYPOGRAPHY */
                  @import '_/sass/typography';
                  /* MOBILE */
                  @import '_/sass/mobile';
                  /* MAIN */
                  @import '_/sass/main';
                  

                  目录结构:

                  ├── _
                  │   ├── inc
                  │   │   ├── stuff
                  │   ├── js
                  │   │   ├── otherstuff.js
                  │   └── sass
                  │       ├── main.scss
                  │       ├── mobile.scss
                  │       ├── print.scss
                  │       ├── reset.scss
                  │       ├── style.scss
                  │       └── typography.scss
                  ├── gulpfile.js
                  └── style.css
                  

                  终端吐出:

                  [gulp] Using file /Users/jeshuamaxey/project/dir/path/gulpfile.js
                  [gulp] Working directory changed to /Users/jeshuamaxey/project/dir/path/html5reset
                  [gulp] Running 'default'...
                  [gulp] Running 'sass'...
                  [gulp] Finished 'sass' in 3.18 ms
                  [gulp] Finished 'default' in 8.09 ms
                  
                  stream.js:94
                        throw er; // Unhandled stream error in pipe.
                              ^
                  source string:11: error: file to import not found or unreadable: 'reset'
                  

                  推荐答案

                  保持导入不变,只需在 gulp sass 模块中传递 includePaths 选项作为参数:

                  Keep your imports as is, just pass the includePaths option in your gulp sass module as an argument:

                  gulp.src('./_/sass/style.scss')
                          .pipe(sass({ includePaths : ['_/sass/'] }))
                          .pipe(gulp.dest('./'));
                  

                  ...应该为你做.

                  根据 https://github.com/dlmanning/gulp-sass/issues/1

                  这篇关于Gulp-sass 无法编译 scss 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何使用 gulp 在浏览器中进行刷新 下一篇:如何在 gulp 中创建重复管道?

                  相关文章

                  最新文章

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

                    <legend id='g1cq2'><style id='g1cq2'><dir id='g1cq2'><q id='g1cq2'></q></dir></style></legend>
                      <bdo id='g1cq2'></bdo><ul id='g1cq2'></ul>

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