A
A
antbelogurov2020-12-23 12:03:51
gulp.js
antbelogurov, 2020-12-23 12:03:51

How to change relative paths in gulp?

At the moment, I write the scss properties like this: url("./../../images/github_btn.svg")
How to make the path output like this url("images/github_btn.svg")

my config

// сборка HTML
gulp.task('html', function (callback) {
  return gulp.src('./app/html/*.html')
    .pipe(fileInclude({
      prefix: '@@'
    }))
    .pipe(gulp.dest('./app/'))

  callback()
})

gulp.task('scss', function (callback) {
  {
    return gulp.src('./app/scss/main.scss')
      .pipe(sourceMap.init())
      .pipe(sass())
      .pipe(autoprefixer({
        overrideBrowserslist: ['last 4 versions']
      }))
      .pipe(sourceMap.write())
      .pipe(gulp.dest('./app/css/'))
    callback()
  }
})

gulp.task('watch', () => {
  watch(['./app/*.html', './app/css/**/*.css',], gulp.parallel(browserSync.reload))

  watch('./app/scss/**/*.scss', function () {
    setTimeout(gulp.parallel('scss'), 1000)
  })

  watch('./app/html/**/*.html', gulp.parallel('html'))
})


//подключили browserSync (читать документацию)
gulp.task('server', () => {
  browserSync.init({
    server: {
      baseDir: "./app/"
    }
  });
});

gulp.task('default', gulp.parallel('server', 'watch', 'scss'))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question