Move css link tag generation to util
This commit is contained in:
parent
9610d244dd
commit
6113d1b575
|
|
@ -25,6 +25,6 @@ jobs:
|
|||
npm -v
|
||||
node -v
|
||||
npm install
|
||||
npm run e2e-test
|
||||
npm run test
|
||||
env:
|
||||
CI: true
|
||||
|
|
|
|||
|
|
@ -6,8 +6,7 @@ const preprocess = require('gulp-preprocess');
|
|||
const rename = require('gulp-rename');
|
||||
const del = require('del');
|
||||
const inlineimg = require('gulp-inline-images-no-http');
|
||||
const path = require('path');
|
||||
const { getConfigsForDir, getFilePathsForDir } = require('./util/util');
|
||||
const { getConfigsForDir, getFilePathsForDir, getCssLinkTagsFromFilelist } = require('./util/util');
|
||||
|
||||
function buildTask(options) {
|
||||
// Requires: 'dupe', 'less', 'sass', 'postcss', 'lint'.
|
||||
|
|
@ -29,12 +28,7 @@ function buildTask(options) {
|
|||
*/
|
||||
const files = await getFilePathsForDir(cwd);
|
||||
const context = Object.assign(conf, {
|
||||
stylesheets: files
|
||||
.filter(file => !!file.match(/.*\.css/)) // Read only CSS files.
|
||||
.reduce((acc, cur) => {
|
||||
const cssPath = path.win32.basename(cur);
|
||||
return (acc += '<link rel="stylesheet" href="' + cssPath + '">');
|
||||
}, '')
|
||||
stylesheets: getCssLinkTagsFromFilelist(files)
|
||||
});
|
||||
|
||||
return options
|
||||
|
|
|
|||
|
|
@ -91,6 +91,20 @@ const getHtmlTemplatesFromFilelist = filelist => {
|
|||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets an array of css link tags from a filelist (if css files are in the filelist).
|
||||
*
|
||||
* @param { Array } filelist
|
||||
*/
|
||||
const getCssLinkTagsFromFilelist = filelist => {
|
||||
return filelist
|
||||
.filter(file => !!file.match(/.*\.css/)) // Read only CSS files.
|
||||
.reduce((acc, cur) => {
|
||||
const cssPath = path.win32.basename(cur);
|
||||
return (acc += '<link rel="stylesheet" href="' + cssPath + '">');
|
||||
}, '');
|
||||
};
|
||||
|
||||
const log = {
|
||||
warn: (...messages) => {
|
||||
console.warn('🔵 ', chalk.yellow(messages));
|
||||
|
|
@ -109,7 +123,8 @@ const self = {
|
|||
log,
|
||||
getConfigsForDir,
|
||||
getFilePathsForDir,
|
||||
getHtmlTemplatesFromFilelist
|
||||
getHtmlTemplatesFromFilelist,
|
||||
getCssLinkTagsFromFilelist
|
||||
};
|
||||
|
||||
module.exports = self;
|
||||
|
|
|
|||
Loading…
Reference in New Issue