V
V
Vasya Bulka2021-05-13 01:52:51
JavaScript
Vasya Bulka, 2021-05-13 01:52:51

Insert variable in gulpfile.js?

Tell me how to insert variables...
For example:

let gHOST= 'host.dev'; // переменная для хоста

function BROWSER_SYNC(none) {
  gBROWSER.init({
    proxy: '${gHOST}' // <-- тут вставить переменную
  });
  return none();
}

or
let gPREPROCESSOR= 'sass'; // переменная компилятора css стилей (less, sass)

function COMPILE_CSS() {
  return src('assets/${gPREPROCESSOR}/main.{scss,less}') // <-- тут вставить переменную
    .pipe(gSASS().on('error', gSASS.logError))
    .pipe(dest('assets/css'));
}


Maybe there is a plugin?
I saw this code:
return src([`themes/${theme}/assets/styles/${preprocessor}/theme.*`, `!themes/${theme}/assets/styles/${preprocessor}/_*.*`])

${gHOST} didn't work for me...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Dubrovin, 2021-05-13
@Anonymous24

To insert a variable into text
1) Use quotes - `${Variable} text`
2) 'text' + Variable + 'text'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question