ANGULAR4 of the road (3) angular foot hand introduced scss

Source: Internet
Author: User
Tags install node npm install node faa

Scss. Sass .... SCCC ... SSSs ... CCCCC ... MMP

First, the similarities and differences between SCSS and sass:

SCSS is Sass 3 introduces the new syntax, its syntax is fully compatible with CSS3, and inherits the powerful features of Sass. In other words, any standard CSS3 style sheet is a valid SCSS file with the same semantics. In addition, SCSS can identify most CSS hacks (some CSS tips) and browser-specific syntax, such as: Old IE filter syntax.

Since SCSS is an extension of CSS, all code that works correctly in CSS can work correctly in SCSS. That is, for a Sass user, it is only necessary to understand how the Sass extension works, to fully understand SCSS. Most extensions, such as variables, parent references, and directives, are consistent, except that SCSS need to use semicolons and braces instead of line wrapping and indentation. For example, here's a simple Sass code:

#sidebar   30%  background-color: #faa

You can convert to SCSS syntax by simply adding curly braces and semicolons:

#sidebar {  30%;  Background-color: #faa;}

In addition, SCSS is not sensitive to whitespace symbols. The above code can also be written in the following way:

#sidebar {width:30%; Background-color: #faa}

Okay, get to the point:

If you create projects with ANGULAR-CLI, your style files want to use SCSS and have ng serve automatically compile them

The first step:

You can use it when creating a project.

New Sassy-project--style=sass

or modify your existing project with NG set Defaults.styleext scss;

Ng Set Defaults.styleext scss

Step Two:

Use NPM tools to install Sass dependencies and loader (NPM can't try CNPM)

NPM Install Node-sass--save-devnpm install sass-loader--save-dev

Step Three:

Modify the. angular-cli.json file

"Styles": [    "Styles.scss"],"Defaults": {    "Styleext": "Scss",    " Component ": {}}

Fourth Step:

"To change a. css file that already exists in the project to a. Scss" project is automatically modified "

Note: The newly created component project will generate the. scss file directly

Creating a new Component: NG G Component Component Name

ANGULAR4 of the road (3) angular foot hand introduced scss

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.