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
AOT: SCSS files are imported in GenDir but linking is wrong #11688
Comments
Please include a repro. |
Typescript version is 2.0.2. Will try to reduce to just the necessary and post it when it's reproducible. |
OK: Archive.zip Compilation will actually fail but you will see in the generated files that the path is incorrect like shown above |
I get this same problem. Is there a solution yet? |
@IgorMinar , Just seen you have flagged the issue with "need: repro", but it's available in the comment just above, as a zip file #11688 (comment). @aedensixty , I have not tried further as I'm running in other issues when doing AOT but, it seems that .css files are not affected, hence renaming scss to css and then changing your webpack config accordingly could make the trick... |
@Krisa I am just doing a gulp-sass build to create css and refer to them to begin with as a workaround for the moment until there is a fix. |
Any news on that? I'm experiencing the same problem. Here a repro |
Have no proper repro, but we too are hitting this same issue. Loaders order for .scss files is: loaders: ['raw-loader', 'postcss-loader', 'sass-loader'], As for others, .shim.ts file is generated under my codegen directory subtree, but generated .directive.ngfactory.ts component is trying to import that from the original src subtree. The original .directive.ts component is including the SCSS file through styleUrls. HTH |
The Relevant error you will receive in the console for this bug looks like this
Still struggling with this and have come to the same conclusion as @aedensixty . I am running a task with Gulp ( Can be done with Webpack also) that Processes all .scss files in the project and outputs a .css in the same directory. Then in your Component reference the generated .css file.
Then after this you can run ngc. This is strange though because you can use the angular-cli to build a project in AoT mode:
with scss files in the styleUrls:[] field. If you call this beforehand:
This build will complete fine with the Tour of Heroes - 6 example from the angular.io repo. I don't know how angular-cli is achieving this. Probably a custom workflow where webpack is perhaps doing what is described above and processing the SCSS into CSS and changing/removing the reference in the styleUrls (Maybe by inlining the styles instead) before ngc runs. One of the reasons I am not using angular-cli to build my app is because it produces a 800Kb non-gzipped bundle when run in --prod and --aot mode. When I build my project with pre-processed SCSS -> CSS using ngc & rollup as in the docs I get a 200Kb bundle. I'm going to guess the cause of this is inferior Tree Shaking. The angular-cli project says in its readme that it performs tree-shaking but I believe it uses Uglify which I've read does a "dumb" tree shake versus rollup's more intricate and better-suited tree shake. This is me speculating based off my limited knowledge and is no way based on an intricate understanding of angular-cli, uglify or rollup. Just what I have read. Such a shame as this is a reason making me apprehensive me using Angular 2 in a production build for a client. AoT Compilation seems so fragile and buggy and Angular 2 is not really viable in the big bad world of development world without a stable AoT Compilation pipeline when there are much more stable competitors. Please set a milestone. I will happily try to fix this problem but I think my competency and knowledge of the compiler is miles away from where it would need to be. If someone wants to direct a dumb pair of monkey hands to where the problem / lack of support for SASS/SCSS might be I'll definitely take a look and if I make any progress submit a PR. As for now I'll be processing my .SCSS in a custom workflow in gulp. I am just putting my experiences and error log here to help anyone who comes across this. As trying to find info about this issue is practically impossible. I have been contending with it for a good 10-15 hours of solid time before finally finding this after an intense session with google and realising it's not my setup or config. |
@Krisa is this still valid in angular 4? can you please update your example? thanks |
@DzmitryShylovich Thanks for coming back on this one. To be honest, I'm not sure whether it's still relevant. I've now switched to the Angular CLI which handles well SCSS. So I'm going to close it. |
It's still happening. CLI Handles SCSS well so |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a Bug (check one with "x")
Current behavior
when running AOT, files are successfully generated in the dist directory. However, the imports are wrong as we can see on this picture:
We can see that the file *.scss.shim.ts is located in the same directory, but instead the compiler expects to find this file in my original directory, i.e. not under
dist
, but undersrc
Expected behavior
the line above shall be written instead
import * as import16 from './edit-audience.scss.shim';
Reproduction of the problem
This is how my source file is looking:
What is the motivation / use case for changing the behavior?
Currently not working. It seems that only inline CSS (or is this because it's SCSS?) is working.
Please tell us about your environment:
Mac, latest version of the compiler-cli: 0.6.2
2.0.0 (but compiler cli 0.6.2)
node --version
= 6.2.0The text was updated successfully, but these errors were encountered: