-
Notifications
You must be signed in to change notification settings - Fork 39
split and rejoin styles in HtmlSplitter and HtmlRejoiner #40
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
CLAs look good, thanks! |
@@ -311,8 +311,8 @@ class HtmlSplitter extends Transform { | |||
for (let i = 0; i < scriptTags.length; i++) { | |||
let scriptTag = scriptTags[i]; | |||
let source = dom5.getTextContent(scriptTag); | |||
let typeAtribute = dom5.getAttribute(scriptTag, 'type'); | |||
let extension = typeAtribute && extensionsForType[typeAtribute] || 'js'; | |||
let typeAttribute = dom5.getAttribute(scriptTag, 'type'); |
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.
haha, nice catch
@hurst looks good! Can you add a test? You can use polymer-build/test/polymer-project_test.js Line 152 in 2b198f5
also /cc @justinfagnani (who originally wrote this logic) for an extra set of eyes |
I stand corrected, see @justinfagnani's comment below. |
The default build from generator-polymer-init-custom-build does not skip the rejoining. I was using a custom gulpfile in a project that would split without rejoining for CSP compliance. I figured that was not supported but there was some talk of it in this issue for polymer-starter-kit. Adding a test for this... |
regarding splitting w/o rejoining, that was always supposed to be supported so that we could deprecate Cripser. |
@@ -356,6 +374,11 @@ class HtmlRejoiner extends Transform { | |||
pred.hasAttr('src') | |||
); | |||
|
|||
static isExternalStyle = pred.AND( |
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.
Is this used anywhere?
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.
Should be used on line 425 but is missing. Will change it to match a <link>
tag as well for matching the changes below.
Sorry for the multiple accounts in here. Was in the middle of converting @hurst into an organization for family use and moving everything into a personal account (@nyanmatt) |
Bump! Is this blocked by anything? @sorvell I believe there's a question for you above |
I talked to Steve, there's no way to make Polymer CSP compliant without style-src: unsafe-inline. |
Yes, from what I can tell it looks very difficult to split inline CSS. The gulp build would have to duplicate the functionality of style-util.html and style transformer.html from the polymer project. If styles can't be externalized, will it still supported to process them in the gulp pipeline for minifying (Issue #32)? |
Splitting and rejoining CSS styles is currently blocked in the polymer-build library (see Polymer/polymer-build#40). Until that issue is resolved and merged, the CLI can still optimize inline styles via css-slam.
* refactor optimize-streams, add better logging * add temporary InlineCSSOptimizeStream to build process Splitting and rejoining CSS styles is currently blocked in the polymer-build library (see Polymer/polymer-build#40). Until that issue is resolved and merged, the CLI can still optimize inline styles via css-slam. * add tests * update CHANGELOG * update test
Superseded by #103 |
fixes #32
One thing to note is that splitting sources and dependencies without rejoining them will no longer work in a custom build. Previously you could splitSource() and splitDependencies() and still having a working site without calling rejoin() (only javascript files would be external).
Since external stylesheets with an include property aren't supported in any way, calling split() without rejoin() can't be supported by polymer-build.
I'm hoping to see this crisper issue resolved to support external stylesheets in the future: PolymerLabs/crisper#32