Skip to content

<no source> seen in generated site map #394

@neway

Description

@neway

I'm using gulp-sourcemaps to build a Post CSS based theme - and am seeing a "no sources" entry in the sources attribute of the generated map file.

using: "gulp-sourcemaps": "^3.0.0" & "gulp-postcss": "^10.0.0",

function styles() {
  const autoprefixer = require('autoprefixer');
  const postcss = require('gulp-postcss');
  const nested = require('postcss-nested');
  const calc = require('postcss-calc');
  const atImport = require('postcss-import');
  const perfectionist = require('perfectionist');
  const postcssCustomMedia = require('postcss-custom-media');
  const postcssCustomProperties = require('postcss-custom-properties');
  const sourcemaps = require('gulp-sourcemaps');
  const rename = require('gulp-rename');

  return gulp.src('./css/neway_mods.pcss')
    .pipe(sourcemaps.init())
    .pipe(postcss([
      atImport(),
      nested(),
      postcssCustomMedia(),
      postcssCustomProperties({ preserve: false }),
      calc(),
      autoprefixer({ grid: 'no-autoplace' }),
      perfectionist({ indentSize: 2 }),
    ]))
    .pipe(sourcemaps.mapSources(function (sourcePath, file) {
      // source paths are prefixed with '../src/'
      return '' + sourcePath;
    }))
    .pipe(rename(function (path) {
      // Updates the object in-place
      if (path.extname == '.pcss') {
        path.extname = '.css';
      }
    }))
    .pipe(sourcemaps.write('.'))
    .on('error', function (errorInfo) {  // if the error event is triggered, do something
      console.log(errorInfo.toString()); // show the error information
      this.emit('end'); // tell the gulp that the task is ended gracefully and resume
    })
    //.pipe(replace(',"<no source>"', ''))
    .pipe(gulp.dest('./css'));
}

This results in the map file:

{"version":3,"sources":["../../../../../core/themes/olivero/css/base/media-queries.pcss.css","neway_mods.pcss","<no source>"],"names":[],"mappings":"AA.....

I've been suppressing the error using a replacement clause at the end of the task - to remove the string - but thought it worthwhile noting here for any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions