javascriptnpmimportgulpgulp-sass

Import two files


Recently started learning imports and faced the following problem
After installing the package in gulpfile, you need to make the following entry:

const sass = require('gulp-sass')(require('sass'));

Can I somehow make this record using import?
The only thing that comes to my mind is:

import gulp_sass from 'gulp-sass';
import sass from 'sass';

But there one variable is assigned two values, and here, in fact, there are 2 "variables" and it turns out somehow not very good because you need to use one name in the task, not two.


Solution

  • I would import from 'sass' with a different name, and construct sass per function call, just like when using require.

    import gulp_sass from 'gulp-sass';
    import _sass_ from 'sass';
    
    const sass = gulp_sass(_sass_);