timpla
Version:
An optimal website development experience for [server-side] web frameworks.
42 lines • 2.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var browserSync = require("browser-sync");
var gulp = require("gulp");
var autoprefixer = require("gulp-autoprefixer");
var cssnano = require("gulp-cssnano");
var gulpif = require("gulp-if");
var sass = require("gulp-sass");
var sourcemaps = require("gulp-sourcemaps");
var internal_1 = require("../internal");
exports.stylesheets = function (_a) {
var stylesheetsOptions = _a.stylesheets;
return function (cb) {
if (stylesheetsOptions === false) {
return cb;
}
var paths = {
dest: internal_1.projectDestPath(stylesheetsOptions.dest),
src: internal_1.projectSrcPath(stylesheetsOptions.src, '**/*.{' + stylesheetsOptions.extensions + '}'),
};
if (stylesheetsOptions.sassOptions.includePaths) {
stylesheetsOptions.sassOptions.includePaths = stylesheetsOptions.sassOptions.includePaths.map(function (includePath) {
return internal_1.projectPath(includePath);
});
}
var currentEnv = internal_1.TIMPLA_PROCESS.isProduction ? 'production' : 'development';
var useSourceMap = stylesheetsOptions[currentEnv] && stylesheetsOptions[currentEnv].sourceMap;
var cssnanoOptions = stylesheetsOptions.cssnanoOptions;
cssnanoOptions.autoprefixer = false; // this should always be false, since we're autoprefixing separately
return gulp
.src(paths.src, stylesheetsOptions.srcOptions)
.pipe(gulpif(useSourceMap, sourcemaps.init()))
.pipe(sass(stylesheetsOptions.sassOptions))
.on('error', internal_1.handleErrors)
.pipe(autoprefixer(stylesheetsOptions.autoprefixerOptions))
.pipe(gulpif(internal_1.TIMPLA_PROCESS.isProduction, cssnano(cssnanoOptions)))
.pipe(gulpif(useSourceMap, sourcemaps.write()))
.pipe(gulp.dest(paths.dest, stylesheetsOptions.destOptions))
.pipe(browserSync.stream());
};
};
//# sourceMappingURL=stylesheets.js.map