Ionic 4 + Angular 6 PWA Styles not working / broken

試著忘記壹切 提交于 2019-12-06 16:55:50

Since Ionic 4 and Angular 6, you have to remove the page / component tag. Please see Migration to Ionic 4 -> https://beta.ionicframework.com/docs/building/migration/#overview

Page/component Sass should no longer be wrapped in the page/component tag and should use Angular's styleUrls option of the @Component decorator

So it's not a bug and everything is working as expected! So please read the migration guide and remove the wrapper and everything should work again

So made some progress on this, and I'll answer my own question for now.

It seems to be an issue with the element selectors in scss files

So if I have scss like this

app-visit {
  .visit-details {
    margin-top: 20px;

    @include mobile-only {
      margin-top: 10px;
    }
  }
  .email-share {
    margin-top: 15px;
  }
  .hidden-email {
    display: none;
    &.active {
      display: block;
    }
    .side-content
    {
      border-left: 1px solid gray;
    }
  }
}

the PWA build fails to include the styles for that component

if I remove the app-visit wrapper then it works on the PWA build!

I'm guessing there's a deeper issue here that I don't understand but I'll make some posts with the Ionic and Angular teams.

But if you are experiencing this, then this is a good work-around for now

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!