Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generated sourcemaps missing path #731

Closed
dungdm93 opened this issue Oct 11, 2016 · 10 comments
Closed

generated sourcemaps missing path #731

dungdm93 opened this issue Oct 11, 2016 · 10 comments

Comments

@dungdm93
Copy link

dungdm93 commented Oct 11, 2016

I use autoprefixer with gulp, but generated sourcemaps seem to have only files name in sources attribute.

src
|- app
|   \- components.css
\- main.css
// gulpfile.js
var $ = require("gulp-load-plugins")({ lazy: true });

gulp.task("compile:styles", function () {
    return gulp
        .src("./src/**/*.css")
        .pipe($.sourcemaps.init())
        .pipe($.autoprefixer())
        .pipe($.concat("styles/all.css"))
        .pipe($.sourcemaps.write(".", {includeContent: false, sourceRoot: '../src'}))
        .pipe(gulp.dest("./dist"));
});

Actual result:

// dist/styles/all.css.map

{"version":3,"sources":["styles.css","components.css"],"names":[],"file":"styles/all.css","sourceRoot":"../src","mappings":"..."}
// missing path ------------------------^

Expected result (when I disable autoprefixer):

{"version":3,"sources":["styles.css","app/components.css"],"names":[],"file":"styles/all.css","sourceRoot":"../src","mappings":"..."}
@ai
Copy link
Member

ai commented Oct 11, 2016

You need to set sourceContent option to PostCSS.

@ai ai closed this as completed Oct 11, 2016
@dungdm93
Copy link
Author

I don't use autoprefixer as PostCSS plugin.
I use standalone gulp-autoprefixer

@ai
Copy link
Member

ai commented Oct 11, 2016

There is no standalone Autoprefixer 😉. gulp-autoprefixer just have hidden PostCSS inside.

In Gulp you need to enable sourceContent in gulp-sourcemaps. PostCSS will use previous source map settings.

@dungdm93
Copy link
Author

dungdm93 commented Oct 11, 2016

gulp-sourcemaps has no sourceContent option.
The only similar one is includeContent, but I'd like to use external source so... as you see, I set it false
{includeContent: false, sourceRoot: '../src'}

@ai
Copy link
Member

ai commented Oct 11, 2016

includeContent is what you need, it will add sourceContent to map.

@ai
Copy link
Member

ai commented Oct 11, 2016

Ouh, I found what you mean 😕

@ai
Copy link
Member

ai commented Oct 11, 2016

Could you try gulp-postcss with autoprefixer. And if you will have problem open a issue in PostCSS repo?

Autoprefixer doesn't add maps, only PostCSS does it

@dungdm93
Copy link
Author

:) Let me try.

@dungdm93
Copy link
Author

gulp-postcss with autoprefixer work fine 👍
But should gulp-autoprefixer also support sourcemaps?

@ai
Copy link
Member

ai commented Oct 11, 2016

It should, but maybe it contains some mistake?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants