angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Q: Using compass and other sass mixins with angular-cli?

Open m-abs opened this issue 10 years ago • 11 comments

I can see compass support recently have been removed from angular-cli, is there a way to install it ourselves in our project?

What about other sass mixins like sass-flex-mixin? I've tried to install the node module and add the path ../node_modules/sass-flex-mixin/_flex.scss to styles in our angular-cli.json file, but I just get this error:

ERROR in ./src/app/app.component.scss
Module build failed: 
@import "sass-flex-mixin/_flex";
^
      File to import not found or unreadable: sass-flex-mixin/_flex

m-abs avatar Sep 14 '16 19:09 m-abs

sass / webpack has a special way of including other node_module packages.

if you write ~ before the import it goes and looks for it in node_modules

@import "~sass-flex-mixin/_flex";

https://github.com/jtangelder/sass-loader#imports

leon avatar Sep 15 '16 06:09 leon

See https://github.com/angular/angular-cli/issues/1656 for a discussion regarding overriding webpack config.

Your imports can reference node_modules either by using ~ as @leon suggested, or by putting in the full relative path (../../node_modules/sass-flex-mixin/_flex).

filipesilva avatar Sep 21 '16 16:09 filipesilva

@m-abs Were you able to include compass as a third party library? Or any other library?

neha-s16 avatar Jan 16 '17 21:01 neha-s16

@neha-s16 We moved away from angular-cli, it was too much overhead for our needs.

m-abs avatar Jan 16 '17 21:01 m-abs

@m-abs So what did you use instead? We are facing too many issues as well.

neha-s16 avatar Jan 16 '17 21:01 neha-s16

@neha-s16 I wish I could give you simple answer with just one tool, but I can't.

Our main project is based on this seed-project https://github.com/NathanWalker/angular-seed-advanced. It gives us the tooling needed to develop for web, desktop (electron) and mobile (nativescript) with a shared code base.

Our real problem were our modules and their demo projects. We started out with the angular-cli, which isn't/wasn't geared towards developing modules, when we ran into this issue we decided to switch to gulp. I've a baseproject we used: https://github.com/m-abs/typescript-baseproject/tree/ng2-ngc (sorry not up-to-date). But after we ran into some problems with building and publishing modules with ngc-metadata, we started to move away from gulp and I think we'll end up using npm scripts for building all our modules. These scripts run tsc, ngc, tslint, node-sass and so on.

We have a simple web-app based on https://github.com/manekinekko/angular-aot-demo It's just a demo for building with AOT, but it was enough for our need.

I think I'd look at https://github.com/mgechev/angular-seed if I were to make a web-only app today. It's the project the seed we use is based upon.

m-abs avatar Jan 16 '17 23:01 m-abs

See https://github.com/angular/angular-cli/wiki/stories-global-styles from https://github.com/angular/angular-cli/issues/2880#issuecomment-288404419

raff77 avatar Mar 29 '17 09:03 raff77

if there is any issue in the scss mixin Module build failed: @import "~compass-mixins/lib/compass"; ^ File to import not found or unreadable: ~compass-mixins/lib/compass.

so solution is

  1. npm install compass-mixins
  2. npm install compass-mixins --save that save your file or package.

then run ng serve

elegance-pooja-123 avatar Jul 28 '17 11:07 elegance-pooja-123

Thanks @elegance-pooja-123

UmarEhsan avatar Jan 22 '18 10:01 UmarEhsan

The problem shows while run "ngc", but works good while run "ng serve" !

moamen-ui avatar Oct 03 '18 06:10 moamen-ui

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.