css - gulp-sourcemap file extension issue -


trying create gulp file picks our less files , generates appropriate .css, .min.css, , .css.map files. close, sourcemaps writing map file extension .css.min.css.

/// <vs beforebuild='less' solutionopened='less' /> /// <binding beforebuild='less' projectopened='less' /> var gulp = require('gulp'); var less = require('gulp-less'); var sourcemaps = require('gulp-sourcemaps'); var autoprefixer = require('autoprefixer'); var minifycss = require('gulp-minify-css'); var pleeease = require('gulp-pleeease'); var rename = require('gulp-rename'); var mqpacker = require('css-mqpacker'); var csswring = require('csswring'); var postcss = require('gulp-postcss');  var processors = [         autoprefixer({ browsers: ["ie >= 9, firefox > 10, last 2 chrome versions, last 2 safari versions, last 2 ios versions"] }),         mqpacker ]; gulp.task('less', function () {     gulp.src('./itims/content/*.less', { base: './itims/content'})         .pipe(sourcemaps.init())         .pipe(less())         .pipe(postcss(processors))         .pipe(rename({             extname: '.css'         }))         .pipe(gulp.dest('./itims/content'))         .pipe(minifycss())         .pipe(sourcemaps.write('./'))         .pipe(rename({             suffix: '.min',             extname: '.css'         }))         .pipe(gulp.dest('./itims/content')); }); 

as might guess, problem comes rename after sourcemaps.write. want rename *.css files, hence following solution should trick :

  1. add gulp-if dependencies if not present

    var if = require('gulp-if'); 
  2. rewrite task follows :

    gulp.src('./itims/content/*.less', {base: './itims/content'})     .pipe(sourcemaps.init())     .pipe(less())     .pipe(postcss(processors))     .pipe(gulp.dest('./itims/content'))     .pipe(minifycss())     .pipe(sourcemaps.write('./'))     .pipe(if('*.css', rename({extname: '.min.css'}))     .pipe(gulp.dest('./itims/content')); 

notes:

  • i removed first rename less plugin handles renaming of *.less *.css
  • beware of case in path names. mixed './itims/content' , './itims/content'.

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -