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

Set correct from and to options for using with source maps. #14

Closed
Panya opened this issue Oct 22, 2014 · 3 comments
Closed

Set correct from and to options for using with source maps. #14

Panya opened this issue Oct 22, 2014 · 3 comments

Comments

@Panya
Copy link

Panya commented Oct 22, 2014

When you are using autoprefixer-stylus with source maps, like:

stylus style.styl -u autoprefixer-stylus -m

now autoprefixer detects sourceMappingURL in the compiled css and rewrites it to sourceMappingURL=to.css (and breaks Stylus' source map link). This is important to set correct from and to options in the autoprefixer-core lib (see autoprefixer-core usage for more info).

I suggest to set these options automatically in the plugin:

var ap = require('autoprefixer-core')
  , path = require('path');

module.exports = function(opts) {
  return function(style){
    style = this || style;
    var filename = style.options.filename;

    style.on('end', function(err, css){
      var processOptions = {
        from: filename,
        to: path.join(
          path.dirname(filename),
          path.basename(filename, path.extname(filename))
        ) + '.css'
      };

      if (opts) return ap(opts).process(css, processOptions).css;
      return ap.process(css, processOptions).css;
    });
  }
};
@jescalan
Copy link
Owner

Hey @Panya -- thanks for the heads up. I'll get these changes in and shipped shortly 👬

@jescalan
Copy link
Owner

Closed by 74bba65 and released as 0.3.1

@Panya
Copy link
Author

Panya commented Oct 23, 2014

Thanks for the fix 👍

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