newsreader/gulp/sass.js
2020-02-08 12:18:45 +01:00

46 lines
1.6 KiB
JavaScript

import { dest, series, src } from 'gulp';
import concat from 'gulp-concat';
import path from 'path';
import sass from 'gulp-sass';
const PROJECT_DIR = path.join('src', 'newsreader');
const SRC_DIR = path.join(PROJECT_DIR, 'scss');
const STATIC_SUFFIX = 'dist/css/';
export const ACCOUNTS_DIR = path.join(PROJECT_DIR, 'accounts', 'static', 'accounts');
export const CORE_DIR = path.join(PROJECT_DIR, 'news', 'core', 'static', 'core');
export const COLLECTION_DIR = path.join(
PROJECT_DIR,
'news',
'collection',
'static',
'collection'
);
const taskMappings = [
{ name: 'login', destDir: `${ACCOUNTS_DIR}/${STATIC_SUFFIX}` },
{ name: 'register', destDir: `${ACCOUNTS_DIR}/${STATIC_SUFFIX}` },
{ name: 'activate', destDir: `${ACCOUNTS_DIR}/${STATIC_SUFFIX}` },
{ name: 'password-reset', destDir: `${ACCOUNTS_DIR}/${STATIC_SUFFIX}` },
{ name: 'homepage', destDir: `${CORE_DIR}/${STATIC_SUFFIX}` },
{ name: 'categories', destDir: `${CORE_DIR}/${STATIC_SUFFIX}` },
{ name: 'category', destDir: `${CORE_DIR}/${STATIC_SUFFIX}` },
{ name: 'rules', destDir: `${COLLECTION_DIR}/${STATIC_SUFFIX}` },
{ name: 'rule', destDir: `${COLLECTION_DIR}/${STATIC_SUFFIX}` },
{ name: 'import', destDir: `${COLLECTION_DIR}/${STATIC_SUFFIX}` },
];
export const sassTask = done => {
const tasks = taskMappings.map(taskMapping => {
const { name, destDir } = taskMapping;
return () =>
src(`${SRC_DIR}/pages/${name}/index.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(concat(`${name}.css`))
.pipe(dest(destDir));
});
series(...tasks)(done);
};