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

Doesn't work with Angular 6 when built with production mode #77

Closed
chakib-mohamed opened this issue May 20, 2019 · 5 comments
Closed

Doesn't work with Angular 6 when built with production mode #77

chakib-mohamed opened this issue May 20, 2019 · 5 comments
Labels

Comments

@chakib-mohamed
Copy link

Hello,

It seems that the example provided in : https://stackblitz.com/edit/css-vars-ponyfill-29 dosn't work in IE11 when i start the application with production mode enabled : ng serve --prod
Do you have any idea of the origin of the problem ?

Thanks in advance.

@steven-hyde
Copy link

steven-hyde commented May 20, 2019

We have the same problem. Everything seems to work fine when debugging using localhost, however once we compile the code using Angular 6 CSS Vars no longer works in IE11.

Here is an example of what the CSS of a button we use looks like when compiled in Angular 6,
IE11_Compiled

And here is an example of the CSS of that same button using localhost debug of Angular 6,
IE11_Debug

I would like to add some additional information. We use the "watch" config in order to support angular encapsulation. Items that are encapsulated are working properly even when compiled as long as we're using the watch command. Here is an example of that,
IE11_AngularEncapsulation

It's only components that are not encapsulated that are not working. (In the above examples we are using the color black for all our variables for testing. All components should be black.)

@winnemucca
Copy link

@steven-hyde @chakib-mohamed Does this not require a JavaScript option? I opened up the stackblitz and see :root. Still learning this myself, to be honest. If you guys figured this out only using css I would love to see your approach.

@jhildenbiddle
Copy link
Owner

@chakib-mohamed, @steven-hyde, @winnemucca --

Apologies for the delayed response. I was focused on other tasks for a few months, but I am now trying to catch up on GitHub issues.

I make no claims of being an Angular expert so perhaps I'm missing something, but I was able to put together a demo of the ponyfill working with Angular 6 in production mode on StackBlitz:

Setup was pretty simple once the basic Angular app was in place:

  1. Install css-vars-ponyfill as a dependency
  2. Enable legacy polyfills in polyfills.ts
  3. Add css-vars-ponyfill to polyfills.ts
  4. Add sample styles to styles.css
  5. Call enableProdMode() in main.ts to enable production mode
  6. Toggle the preview window in StackBlitz (required when swapping between dev/prod mode -- see this StackOverflow answer for details)

Tested in IE by loading the preview window only (https://css-vars-ponyfill-77.stackblitz.io/). Works as expected, with ponyfill-processed CSS available in the console.

Screen Shot 2019-08-03 at 11 42 03 PM

Happy to help investigate further if needed, but as I mentioned my Angular skills are limited.

@jhildenbiddle
Copy link
Owner

@chakib-mohamed, @steven-hyde, @winnemucca --

Since I have not heard back, I am going to assume this issue has been resolved. I am happy to investigate further if you are able to provide additional information that allows me to reproduce the error.

@mdonjones
Copy link

We were having the exact same issue - everything working fine on localhost, but after deployment components that were not encapsulated were not being properly styled in IE11. We managed to get around the issue by setting the extractCss compiler option in angular.json to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants