Skip to content

Bundle workflow does not support css extension in Angular styleUrls when using scss #4804

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

Closed
DimitarTachev opened this issue Jul 4, 2019 · 5 comments
Labels
docs migration-to-bundle The issue is describing a breaking change in the Bundle workflow compared to the Legacy one. question
Milestone

Comments

@DimitarTachev
Copy link
Contributor

DimitarTachev commented Jul 4, 2019

I've just updated the CLI and started using the new workflow to build the app. The app builds fine and typescript changes are picked up properly and compiled to JS and kicks off a build

Changes done to scss files however do not. This not working makes the entire switch to this build process moot for me. Does anyone have any workarounds yet?

Originally posted by @Manbearpixel in #4624 (comment)
and @Manbearpixel in #4624 (comment)

@DimitarTachev DimitarTachev added migration-to-bundle The issue is describing a breaking change in the Bundle workflow compared to the Legacy one. question labels Jul 4, 2019
@DimitarTachev
Copy link
Contributor Author

Hi @Manbearpixel,

Thanks for providing a sample application!

The issue is caused by the styleUrls properties in your Angular components. All of them were configured with .css files. For example:

import { Component, Input } from "@angular/core";

@Component({
  selector: "CreateConversationScreen, [CreateConversationScreen]",
  templateUrl: "./conversation.component.html",
  styleUrls: ['./conversation.component.css'] // <-- the styles file is set with .css extension
})
export class CreateConversationScreenComponent {
  @Input() active: boolean;
  constructor() {

  }
}

The Bundle workflow is not generating any css files in your app folder, it directly transpiles the scss files into css in memory. In other words, you have to refer your styles with their scss extensions. For example:

replace

styleUrls: ['./conversation.component.css'] 

with

styleUrls: ['./conversation.component.scss']

You have to repeat this step for each of your components.

Regarding the scss changes that are not applied, most probably you've run the app with the Legacy workflow on the same machine and you have both .css and .scss files. In this way, the Webpack process uses the auto-generated by the Legacy Workflow .css files (which are gitignored in your app) and the .scss files are not included in its compilation. That's the reason you are not getting a build time exception for missing .css files and the changes in .scss files are not working. If you reset your git repo, you will get a lot of build time errors for missing css files.

I also noticed that you are using an old version of nativescript-dev-webpack and I highly recommend you update to the latest version by executing the following commands:

  1. npm i nativescript-dev-webpack@latest --save-dev
  2. ./node_modules/.bin/update-ns-webpack --configs

@Manbearpixel
Copy link

@DimitarTachev Thank you for taking the time to look into this! Based on your feedback, let me make sure I follow your recommended changes:

  • Replace all instances of styleUrls: ['./conversation.component.css'] with styleUrls: ['./conversation.component.scss']
  • Update nativescript-dev-webpack

I'll give this a whirl and let you know how it goes! I had assumed that the end result (the stylesheet) had to be css as scss wouldn't work directly with the app.

@rosen-vladimirov
Copy link
Contributor

Hey @Manbearpixel ,
Is there any update on this case? Did you have time to give it a try?

@Manbearpixel
Copy link

@rosen-vladimirov Yes, sorry! Took some time testing it out as NS 6 was just released as well so I went to test that migration.

Thanks again!

@rosen-vladimirov
Copy link
Contributor

Hey @Manbearpixel ,
Can we close this issue?

@Fatme Fatme closed this as completed Jul 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs migration-to-bundle The issue is describing a breaking change in the Bundle workflow compared to the Legacy one. question
Projects
None yet
Development

No branches or pull requests

4 participants