-
Notifications
You must be signed in to change notification settings - Fork 201
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
polymer-bundler breaks css image paths #1988
Comments
Are you using |
Here's the test repo for replicate above issue: https://github.com/jaichandra/polymer-bundler-test |
@jaichandra It appears that vulcanize and polymer-bundler have apparently been doing exactly the wrong thing here since... forever, with respect to rewriting the templated I am really surprised this hasn't been reported as a bug until now. Also, we have four unit tests which are designed to assert it does precisely the current incorrect behavior. 👎 Fixing this immediately. |
…m-module> tags of inlined html imports were being rewritten, but were duplicating and thereby foiling the work of the Polymer's own application of the assetpath property of the dom module.
…m-module> tags of inlined html imports were being rewritten, but were duplicating and thereby foiling the work of the Polymer's own application of the assetpath property of the dom module.
I think I've just encountered the same issue using vulcanize 1.15.3. Project structure: app After vulcanized the assetpath of the bundled dom-module is set to I'm a little confused where |
We recently made a patch to vulcanize as well as polymer-bundler for a different problem and will release that soon. If its not too difficult we'll patch vulcanize for this flaw as well. However, definitely recommend you move to polymer-bundler. It's got feature parity with vulcanize and a whole lot more. Polymer Bundler is basically the 2.0 or successor to vulcanize. You can use it with the |
@brettpostin vulcanize and polymer-bundler are essentially completely separate. vulcanize is discontinued though a couple of emergency patches are being made. polymer-bundler is a near complete rewrite and is based on polymer-analyzer, supports multi-bundle aka "sharded" build strategies and is much more flexible than vulcanize. |
FWIW, investigating this issue yielded another related problem with the inlining of stylesheet content inside of dom-modules (inlined stylesheet imports inside dom-modules DO need to have their urls adjusted, but need to incorporate the dom-module assetpath into the resolution of the urls.) That has also been addressed in PR #580 |
) * Fixed issue #579 where url() values inside `<style>` tags inside of `<dom-module>` tags of inlined html imports were being rewritten, but were duplicating and thereby foiling the work of the Polymer's own application of the assetpath property of the dom module. * Added comment to import utils and removed extraneous argument in its tests * Added comments to bundler tests about the url rewrite * Updated to allow rewriteUrlsInTemplates to rewrite style tags in templates. No style tags in dom-modules are rewritten at all. * Fixed the rewriting of style content to observe containing dom-module assetpath. * Fixed a bad test, which was trying to overcorrect urls in inlined styles. Guarded against infinite loop. * Fixup the findAncestor function. * More comments to explain what's going on. * CHANGELOG updated
@jaichandra polymer-bundler v2.3.0 was released with this fix. npm install it and try it out :) |
@usergenic Thought that was the case, thanks for the clarification. I have previously attempted to upgrade to polymer-build/polymer-bundler (see here) but due to lack of guidance and time constraints had to postpone. Are you able to offer any guidance on our specific scenario (i.e. non shell / element project)? Our current gulp build task simply takes in the root html imports and spits out individual bundle files:
How would the same be achieved using polymer-bundler? |
Failing that a patch to vulcanize would be extremely welcome too! |
) * Fixed issue #579 where url() values inside `<style>` tags inside of `<dom-module>` tags of inlined html imports were being rewritten, but were duplicating and thereby foiling the work of the Polymer's own application of the assetpath property of the dom module. * Added comment to import utils and removed extraneous argument in its tests * Added comments to bundler tests about the url rewrite * Updated to allow rewriteUrlsInTemplates to rewrite style tags in templates. No style tags in dom-modules are rewritten at all. * Fixed the rewriting of style content to observe containing dom-module assetpath. * Fixed a bad test, which was trying to overcorrect urls in inlined styles. Guarded against infinite loop. * Fixup the findAncestor function. * More comments to explain what's going on. * CHANGELOG updated
Hey @jaichandra and @brettpostin just a heads up I had to rollback this fix in v2.3.1 because it was a breaking change for polymer 1.x cases I didn't know about. Bundler 3.0.0 will roll out with this fix shortly, because it is a breaking change. |
but you can still get it if you install polymer-bundler@2.3.0 explicitly. |
…th backwards-compatible flag (#588) * Fix invalid url-rewriting in inlined templated element style tags. (#580) * Fixed issue #579 where url() values inside `<style>` tags inside of `<dom-module>` tags of inlined html imports were being rewritten, but were duplicating and thereby foiling the work of the Polymer's own application of the assetpath property of the dom module. * Added comment to import utils and removed extraneous argument in its tests * Added comments to bundler tests about the url rewrite * Updated to allow rewriteUrlsInTemplates to rewrite style tags in templates. No style tags in dom-modules are rewritten at all. * Fixed the rewriting of style content to observe containing dom-module assetpath. * Fixed a bad test, which was trying to overcorrect urls in inlined styles. Guarded against infinite loop. * CHANGELOG updated * Make rewriteUrlsInTemplates effect <style> tag rewriting.
@jaichandra and @brettpostin polymer-bundler 3.0.0 released with the fix back in it. |
I still see the issue with 3.0.1 where as bundling with 2.3.0 works for me. For the following file structure
2.3.0 bundler generates relative reference as follows <dom-module id="my-component" assetpath="./bower_components/ui-components/my-component/">
<template>
<style include="my-component-styles">
.selector {
border-image: url("../images/texture.png");
}
</style>
</template>
</dom-module> where as 3.0.x generates the absolute path resulting a wrong path for the asset as it will be relatively referenced with assetpath of module. .selector {
border-image: url("./bower_components/ui-components/images/texture.png");
} In this case final path turns out to be ./bower_components/ui-components/my-component/bower_components/ui-components/images/texture.png |
@madhusudhand I tested this example (https://github.com/jaichandra/polymer-bundler-test) and it seems to work fine now with v3.0.1. |
@usergenic I came across this path issue again in a different project that has the same structure as in this example Any idea why this is so? I am not able to understand why an explicit |
FWIW, https://github.com/Polymer/polymer-cli/blob/master/src/build/build.ts#L91 in CLI basically checks which version of Polymer is being used if no explicit |
Thanks.. That helps. |
My application has below project structure:
I have a style with below css in
my-library
folder:After I run
polymer-bundler
on elements.html, I see below url in the bundled file:When I run this project locally, the final path that browser looks for is
http://localhost:4200/assets/bower_components/my-library/x-foo/bower_components/my-library/assets/texture.png
I think the style urls should not be updated by
polymer-bundler
.The text was updated successfully, but these errors were encountered: