Move css link tag generation to util
This commit is contained in:
parent
9610d244dd
commit
6113d1b575
|
|
@ -25,6 +25,6 @@ jobs:
|
||||||
npm -v
|
npm -v
|
||||||
node -v
|
node -v
|
||||||
npm install
|
npm install
|
||||||
npm run e2e-test
|
npm run test
|
||||||
env:
|
env:
|
||||||
CI: true
|
CI: true
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,7 @@ const preprocess = require('gulp-preprocess');
|
||||||
const rename = require('gulp-rename');
|
const rename = require('gulp-rename');
|
||||||
const del = require('del');
|
const del = require('del');
|
||||||
const inlineimg = require('gulp-inline-images-no-http');
|
const inlineimg = require('gulp-inline-images-no-http');
|
||||||
const path = require('path');
|
const { getConfigsForDir, getFilePathsForDir, getCssLinkTagsFromFilelist } = require('./util/util');
|
||||||
const { getConfigsForDir, getFilePathsForDir } = require('./util/util');
|
|
||||||
|
|
||||||
function buildTask(options) {
|
function buildTask(options) {
|
||||||
// Requires: 'dupe', 'less', 'sass', 'postcss', 'lint'.
|
// Requires: 'dupe', 'less', 'sass', 'postcss', 'lint'.
|
||||||
|
|
@ -29,12 +28,7 @@ function buildTask(options) {
|
||||||
*/
|
*/
|
||||||
const files = await getFilePathsForDir(cwd);
|
const files = await getFilePathsForDir(cwd);
|
||||||
const context = Object.assign(conf, {
|
const context = Object.assign(conf, {
|
||||||
stylesheets: files
|
stylesheets: getCssLinkTagsFromFilelist(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 + '">');
|
|
||||||
}, '')
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return options
|
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 = {
|
const log = {
|
||||||
warn: (...messages) => {
|
warn: (...messages) => {
|
||||||
console.warn('🔵 ', chalk.yellow(messages));
|
console.warn('🔵 ', chalk.yellow(messages));
|
||||||
|
|
@ -109,7 +123,8 @@ const self = {
|
||||||
log,
|
log,
|
||||||
getConfigsForDir,
|
getConfigsForDir,
|
||||||
getFilePathsForDir,
|
getFilePathsForDir,
|
||||||
getHtmlTemplatesFromFilelist
|
getHtmlTemplatesFromFilelist,
|
||||||
|
getCssLinkTagsFromFilelist
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = self;
|
module.exports = self;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue