Webpack configuration: Less file packaging and separation

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

one, less file packaging and separation

1. To use less, first use NPM to install less services, and you need to install Less-loader to use for packaging.

NPM Install less  --save-devnpm install Less

2. Configure in Module

{    /\.less$/, use    : [{        "style-loader"     },{         "css-loader"     },{        "less-loader "     }]}

3, write a div in HTML, create a new less file in the CSS

<div id="leesbox"></div>
@base: Yellowgreen; #leesBox {    width:300px;    height:200px;    Background: @base;}

4, introduced into the Index.js

 from ' ./css/black.less ';

5. Use Webpack to package, enter NPM run server to view the effect

6, less separation

Second, Sass file packaging and Separation

1, installation: Because the sass-loader depends on the node-sass, so you need to install the Node-sass

NPM install node-sass--save-dev npm install sass

The other is basically the same as the less installation

Webpack configuration: Less file packaging and separation

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.