diff --git a/lib/process/process.js b/lib/process/process.js index db8ed78..aa743c7 100644 --- a/lib/process/process.js +++ b/lib/process/process.js @@ -51,16 +51,20 @@ const rcsProcess = (pathString, opts, cb) => { } // sort in case of 'auto' - const cssFiles = filesArray.filter(file => fileExt.css.includes(path.extname(file))); + const cssHtmlFiles = filesArray.filter(file => ( + fileExt.css.includes(path.extname(file)) + || fileExt.html.includes(path.extname(file)) + )); + const fillLibraryFiles = options.type === 'auto' - ? cssFiles + ? cssHtmlFiles : filesArray; // call in series // not all selectors are stored, maybe some selectors are duplicated in different files return async.eachSeries(fillLibraryFiles, (filePath, asyncCb) => { // skip if it is not meant to fill the library - if (options.type !== 'auto' && options.type !== 'css') { + if (options.type !== 'auto' && options.type !== 'css' && options.type !== 'html') { return asyncCb(); } @@ -69,16 +73,20 @@ const rcsProcess = (pathString, opts, cb) => { return asyncCb(errReadFile); } - const availableOptions = { - prefix: options.prefix, - suffix: options.suffix, - replaceKeyframes: options.replaceKeyframes, - preventRandomName: options.preventRandomName, - ignoreAttributeSelectors: options.ignoreAttributeSelectors, - ignoreCssVariables: options.ignoreCssVariables, - }; - - rcs.fillLibraries(bufferData.toString(), availableOptions); + const isHtml = fileExt.html.includes(path.extname(filePath)); + + rcs.fillLibraries( + bufferData.toString(), + { + prefix: options.prefix, + suffix: options.suffix, + replaceKeyframes: options.replaceKeyframes, + preventRandomName: options.preventRandomName, + ignoreAttributeSelectors: options.ignoreAttributeSelectors, + ignoreCssVariables: options.ignoreCssVariables, + codeType: isHtml ? 'html' : 'css', + }, + ); return asyncCb(); }); diff --git a/package.json b/package.json index 7810217..4fa3429 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "glob": "^7.1.1", "json-extra": "^0.5.0", "lodash.merge": "^4.6.1", - "rcs-core": "^2.5.1", + "rcs-core": "^2.6.0", "universalify": "^0.1.2" }, "devDependencies": { diff --git a/test/files/fixtures/html/index-with-style.html b/test/files/fixtures/html/index-with-style.html new file mode 100644 index 0000000..ffdf687 --- /dev/null +++ b/test/files/fixtures/html/index-with-style.html @@ -0,0 +1,20 @@ + + +
+ +