-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rather than requiring users to manually inject both JavaScript and CSS files, bundle Annotator's CSS in the JavaScript bundle. Uses [enhance-css][1] and [clean-css][2] for image inlining and CSS compression, and [insert-css][3] to do the actual injection of a style tag into the page. [1]: https://github.com/jakubpawlowicz/enhance-css [2]: https://github.com/jakubpawlowicz/clean-css [3]: https://github.com/substack/insert-css
- Loading branch information
1 parent
c67c353
commit 56e7ff1
Showing
8 changed files
with
50 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use strict"; | ||
|
||
var path = require('path'); | ||
|
||
var EnhanceCSS = require('enhance-css'); | ||
var CleanCSS = require('clean-css'); | ||
var through = require('through'); | ||
|
||
|
||
module.exports = function (filename) { | ||
if (!/\.css$/i.test(filename)) { | ||
return through(); | ||
} | ||
|
||
var css = ""; | ||
|
||
return through( | ||
function (chunk) { | ||
css += chunk; | ||
}, | ||
function () { | ||
var enhance = new EnhanceCSS({ | ||
rootPath: path.dirname(filename) | ||
}); | ||
var clean = new CleanCSS(); | ||
|
||
css = enhance.process(css).embedded.plain; | ||
css = clean.minify(css).styles; | ||
|
||
var body = "module.exports = " + JSON.stringify(css); | ||
|
||
this.queue(body); | ||
this.queue(null); | ||
} | ||
); | ||
}; |
This file was deleted.
Oops, something went wrong.
56e7ff1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this insert the CSS with a link tag still or does it inline it?
Inlining can be a problem for CSP, I think.