gulp4 - неопределенная переменная: "$ import-counter" в плагине gulp-sass - PullRequest
0 голосов
/ 07 апреля 2020

Когда я создаю свой сайт благодаря gulp4 в gulpfile. js, он возвращает ошибку для gulp-sass.

Задача, которая позволяет мне скомпилировать все мои файлы вместе, является задачей «сборки». Он компилирует несколько задач, которые я создал, как задачу с изображениями, задачу со шрифтом и т. Д. c. Вот фрагмент кода для:

задача 'build':

gulp.task('build', gulp.series('lint', 'docs', 'jsmin', 'cssmin', 'images', 'fonts', 'extras', 'text-en', 'sass', 'js'), () => {
  return gulp.src('dist/**/*').pipe($.size({title: 'build', gzip: true}));
});

Меня интересуют эти две задачи: 'js' и 'sass '(компилирование в задаче' build '). Эти две задачи устанавливают мои css и js файлы из node_modules. Я хочу установить мои модули с npm в gulp4 правильно.

task 'js':

gulp.task('js', function() {
  return gulp.src(
    ['node_modules/**/*.js', 'node_modules/**/*/.min.js'],
    {base:'node_modules'}
  )
  .pipe(gulp.dest('dist/js'))
  .pipe(browserSync.stream());
});

task 'sass ':

gulp.task('sass', function() {
  return gulp.src(
    ['node_modules/**/*.scss', 'node_modules/**/*/.css'],
    {base:'node_modules'}
  )
  .pipe(sass())
  .pipe(gulp.dest('dist/css'))
  .pipe(browserSync.stream());
});

Затем я вызываю эту задачу в своем терминале, чтобы создать свой веб-сайт и запустить его в режиме разработки:

задача' build-production ':

gulp.task('build-production', () => {
  return new Promise(resolve => {
    dev = false;
    runSequence(['clean', 'wiredep'], 'build', resolve);
  });
});

Но так как я добавил задачи 'js' и 'sass', он возвращает эту ошибку:

[19:22:50] Starting 'sass'...
[19:22:54] 'sass' errored after 4.52 s
[19:22:54] Error in plugin 'gulp-sass'
Message:
    node_modules/node-sass/test/fixtures/depth-first/_vars.scss
Error: Undefined variable: "$import-counter".
        on line 1 of node_modules/node-sass/test/fixtures/depth-first/_vars.scss
        from line 1 of node_modules/node-sass/test/fixtures/depth-first/_common.scss
        from line 1 of node_modules/node-sass/test/fixtures/depth-first/a.scss
>> $import_counter: $import_counter + 1;

   -----------------^

Details:
    status: 1
    file: /home/camille/workspace/project/node_modules/node-sass/test/fixtures/depth-first/_vars.scss
    line: 1
    column: 18
    formatted: Error: Undefined variable: "$import-counter".
        on line 1 of node_modules/node-sass/test/fixtures/depth-first/_vars.scss
        from line 1 of node_modules/node-sass/test/fixtures/depth-first/_common.scss
        from line 1 of node_modules/node-sass/test/fixtures/depth-first/a.scss
>> $import_counter: $import_counter + 1;

   -----------------^

    messageFormatted: node_modules/node-sass/test/fixtures/depth-first/_vars.scss
Error: Undefined variable: "$import-counter".
        on line 1 of node_modules/node-sass/test/fixtures/depth-first/_vars.scss
        from line 1 of node_modules/node-sass/test/fixtures/depth-first/_common.scss
        from line 1 of node_modules/node-sass/test/fixtures/depth-first/a.scss
>> $import_counter: $import_counter + 1;

   -----------------^

    messageOriginal: Undefined variable: "$import-counter".
    relativePath: node_modules/node-sass/test/fixtures/depth-first/_vars.scss
    domainEmitter: [object Object]
    domainThrown: false
[19:22:54] 'build' errored after 10 s
[19:22:54] Finished 'build-production' after 10 s

Я нашел несколько решений для моей проблемы, но никто не работает. Если у кого есть идея!

Спасибо

...