Commit a13eabed authored by Nikolay Gromov's avatar Nikolay Gromov

Подпилил автоматизацию

parent 24c376d8
...@@ -185,9 +185,10 @@ function writeSassImportsFile(cb) { ...@@ -185,9 +185,10 @@ function writeSassImportsFile(cb) {
nth.config.addStyleBefore.forEach(function(src) { nth.config.addStyleBefore.forEach(function(src) {
newScssImportsList.push(src); newScssImportsList.push(src);
}); });
nth.blocksFromHtml.forEach(function(block) { let allBlocksWithScssFiles = getDirectories('scss');
let src = `${dir.blocks}${block}/${block}.scss`; allBlocksWithScssFiles.forEach(function(blockWithScssFile){
if(fileExist(src)) newScssImportsList.push(src); if (nth.blocksFromHtml.indexOf(blockWithScssFile) == -1) return;
newScssImportsList.push(`${dir.blocks}${blockWithScssFile}/${blockWithScssFile}.scss`);
}); });
nth.config.addStyleAfter.forEach(function(src) { nth.config.addStyleAfter.forEach(function(src) {
newScssImportsList.push(src); newScssImportsList.push(src);
...@@ -233,8 +234,10 @@ function writeJsRequiresFile(cb) { ...@@ -233,8 +234,10 @@ function writeJsRequiresFile(cb) {
nth.config.addJsBefore.forEach(function(src) { nth.config.addJsBefore.forEach(function(src) {
jsRequires += `require('${src}');\n`; jsRequires += `require('${src}');\n`;
}); });
nth.blocksFromHtml.forEach(function(block) { let allBlocksWithJsFiles = getDirectories('js');
if(fileExist(`${dir.blocks}${block}/${block}.js`)) jsRequires += `require('../blocks/${block}/${block}.js');\n`; allBlocksWithJsFiles.forEach(function(blockWithJsFile){
if (nth.blocksFromHtml.indexOf(blockWithJsFile) == -1) return;
jsRequires += `require('../blocks/${blockWithJsFile}/${blockWithJsFile}.js');\n`;
}); });
nth.config.addJsAfter.forEach(function(src) { nth.config.addJsAfter.forEach(function(src) {
jsRequires += `require('${src}');\n`; jsRequires += `require('${src}');\n`;
...@@ -360,8 +363,13 @@ function serve() { ...@@ -360,8 +363,13 @@ function serve() {
reload, reload,
)); ));
// Стили Блоков: все события // Стили Блоков: изменение
watch([`${dir.blocks}**/*.scss`], { events: ['all'], delay: 100 }, series( watch([`${dir.blocks}**/*.scss`], { events: ['change'], delay: 100 }, series(
compileSass,
));
// Стили Блоков: добавление
watch([`${dir.blocks}**/*.scss`], { events: ['add'], delay: 100 }, series(
writeSassImportsFile, writeSassImportsFile,
compileSass, compileSass,
)); ));
...@@ -449,7 +457,7 @@ function getClassesToBlocksList(file, enc, cb) { ...@@ -449,7 +457,7 @@ function getClassesToBlocksList(file, enc, cb) {
// Класс совпадает с классом-исключением из настроек? // Класс совпадает с классом-исключением из настроек?
if (nth.config.ignoredBlocks.indexOf(item) + 1) continue; if (nth.config.ignoredBlocks.indexOf(item) + 1) continue;
// У этого блока отсутствует папка? // У этого блока отсутствует папка?
if (!fileExist(dir.blocks + item)) continue; // if (!fileExist(dir.blocks + item)) continue;
// Добавляем класс в список // Добавляем класс в список
nth.blocksFromHtml.push(item); nth.blocksFromHtml.push(item);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment