Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | import * as autoprefixer from 'autoprefixer' import * as browserSync from 'browser-sync' import * as cssnano from 'cssnano' import * as gulp from 'gulp' import * as gulpif from 'gulp-if' import * as postcss from 'gulp-postcss' import * as sass from 'gulp-sass' import * as sourcemaps from 'gulp-sourcemaps' import { handleErrors, ITimplaTask, projectDestPath, projectPath, projectSrcPath, TIMPLA_PROCESS as TP, } from '../internal' export const stylesheets: ITimplaTask = ({ stylesheets: stylesheetsOptions }) => cb => { if (stylesheetsOptions === false) { return cb } const paths = { dest: projectDestPath(stylesheetsOptions.dest), src: projectSrcPath(stylesheetsOptions.src, '**/*.{' + stylesheetsOptions.extensions + '}'), } if (stylesheetsOptions.sassOptions.includePaths) { stylesheetsOptions.sassOptions.includePaths = stylesheetsOptions.sassOptions.includePaths.map( includePath => { return projectPath(includePath) } ) } const currentEnv = TP.isProduction ? 'production' : 'development' const useSourceMap = stylesheetsOptions[currentEnv] && stylesheetsOptions[currentEnv].sourceMap const postcssOptions = stylesheetsOptions.postcssOptions const autoprefixerOptions = stylesheetsOptions.autoprefixerOptions const cssnanoOptions = stylesheetsOptions.cssnanoOptions const postcssPlugins = [ autoprefixer(autoprefixerOptions), TP.isProduction && cssnano(cssnanoOptions), ].filter(Boolean) return gulp .src(paths.src, stylesheetsOptions.srcOptions) .pipe(gulpif(useSourceMap, sourcemaps.init())) .pipe(sass(stylesheetsOptions.sassOptions)) .on('error', handleErrors) .pipe(postcss(postcssPlugins, postcssOptions)) .pipe(gulpif(useSourceMap, sourcemaps.write())) .pipe(gulp.dest(paths.dest, stylesheetsOptions.destOptions)) .pipe(browserSync.stream()) } |