Angular CLI 'ng serve' to ignore less and use available css

谁都会走 提交于 2019-12-08 05:42:05

问题


I am using Angular CLI for Angular2 project. And I am using less for my styling.

To compile less file with Angular CLI, I have to import less file with its absolute path. Which breaks editor's intellisense. So instead of using LESSPlugin comes with AngularCLI, I want to use IDE's less watcher and compiler (available in vs code as well as webstorme) to compile less to css.

But there are less files still exists in source, 'ng serve' try to compile less and that breaks the build.

Is there any way to configure angular cli to ignore less file and use available css in source folder?


回答1:


I manage to do that by uninstalling less module from project using 'npm uninstall less --save-dev'

Now I can use relative path for less import and also intellisense is working now.




回答2:


When you generate a new project using angular cli, type a command like below:

ng new new-project --style less

It will setup your project using less. When you serve(run) the project each time, angular cli will automatically compile your less files.

According to ng command manual

ng new <options...>

--style (String) (Default: css)


来源:https://stackoverflow.com/questions/38192901/angular-cli-ng-serve-to-ignore-less-and-use-available-css

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