T
T
to_east2018-07-06 15:57:35
gulp.js
to_east, 2018-07-06 15:57:35

Gulp passing parameters between tasks?

Greetings Toaster Members!
I will try to explain in more detail the essence of my problem.
In general, we have two asset location directories related to two applications:
$assets_dir = ${project_dir}/apps/public/assets
$assets_dir = ${project_dir}/apps/admin/assets
then the path to the css-style source is as follows:
${assets_dir }/stylesheets/src/style.scss
I need to put the assembled style bundle in a directory below src:
${assets_dir}/stylesheets/bundle.css

// gulpfile.js
const gulp = require('gulp');
const path = require('path');

const assets_dir = './apps/*/assets';

gulp.task('sass', function(cb) {
  // get watched full_path?
});

gulp.task('watch', function () {
  gulp.watch(assets_dir + '/stylesheets/src/**/*.scss', ['sass']);
});

gulp.task('default', ['watch']);

How can I get the full path of the modified file in the 'sass' task?
Found, you can intercept the 'onchange' event and extract the path to the file, something like this:
ulp.watch(assets_dir + '/stylesheets/src/**/*.scss').on('change', function(file) { console.log(file.path); });

But then I need to somehow pass the resulting file to the 'sass' task for further processing.
It's just reluctance to describe tasks for each application.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
to_east, 2018-07-06
@to_east

In general, I revised, it turns out everything is simpler:

gulp.task('sass', function () {
  gulp.watch(assets_dir + '/stylesheets/src/**/*.scss', function(e) {
    console.log(e.path);
    // Building
  });
});

gulp.task('default', ['sass']);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question