Skip to content

Instantly share code, notes, and snippets.

@hail2u
Last active August 29, 2015 14:22
Show Gist options
  • Save hail2u/c165618ee5b05f8d2de0 to your computer and use it in GitHub Desktop.
Save hail2u/c165618ee5b05f8d2de0 to your computer and use it in GitHub Desktop.
Source Maps Splitting test
"use strict";
var fs = require("fs");
var postcss = require("postcss");
var input = fs.readFileSync("test.css");
var output = function (result) {
fs.writeFileSync(result.opts.to, result.css);
if (result.opts.map && result.map) {
fs.writeFileSync(result.opts.to + ".map", result.map);
}
};
postcss().use(function (css) {
css.last.removeSelf();
return css;
}).process(input, {
from: "test.css",
map: true,
to: "test-1.css"
}).then(output);
postcss().use(function (css) {
css.first.removeSelf();
return css;
}).process(input, {
from: "test.css",
map: true,
to: "test-2.css"
}).then(output);
{
"dependencies": {
"postcss": "^4.1.11"
}
}
.a {
color: red;
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBO0VBQ0UsV0FBVztDQUNaIiwiZmlsZSI6InRlc3QtMS5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIuYSB7XG4gIGNvbG9yOiByZWQ7XG59XG5cbi5iIHtcbiAgY29sb3I6IGdyZWVuO1xufVxuIl19 */
.b {
color: green;
}
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInRlc3QuY3NzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUlBO0VBQ0UsYUFBYTtDQUNkIiwiZmlsZSI6InRlc3QtMi5jc3MiLCJzb3VyY2VzQ29udGVudCI6WyIuYSB7XG4gIGNvbG9yOiByZWQ7XG59XG5cbi5iIHtcbiAgY29sb3I6IGdyZWVuO1xufVxuIl19 */
.a {
color: red;
}
.b {
color: green;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width" name="viewport">
<title>Source Maps Splitting</title>
<link href="./test-1.css" rel="stylesheet">
<link href="./test-2.css" rel="stylesheet">
</head>
<body>
<header>
<h1>Source Maps Splitting</h1>
</header>
<div class="a">This is a.</div>
<div class="b">This is b.</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment