Webpack working with resource files in a project

Source: Internet
Author: User
Tags postcss

Loader: Can be synchronous asynchronous, can be used in the Nodejs, with parameters, can let webpack to do what it does not support such as the style-loader we used before, the common way is in Webpack.config.js loader configuration

Installing BABEL-LOADER:NPM install--save-dev Babel-loader babel-core

3. Installing LATEST:NMP Install--save-dev babel-preset-latest

4. Can be configured in the Package.json latest, can also be directly written in Webpack.config.js

"Label": {

"Presets": ["latest"]

}

5. Deal with some CSS not easy to be parsed by the browser things we need to install after the processor NPM install Postcss-loader--save-dev

POSTCSS plugin autoprefixer npm install autoprefixer--save-dev

6. Use the less file to install NPM I less-loader--save-dev

7. Working with a static HTML template file requires installing NPM install Html-loader--save-dev

8. Processing the Ejs template file requires the installation of Ejs-loader, and the loader is configured in the Webpack-config file.

9. Processing picture File Installation File-loader

9.1: Working with images introduced in CSS

9.2: Picture introduced by the way IMG is processed

9.3: The reference picture in the component (if you want to use a relative path requires ${require ('. /img/aa.png ')})

10. Install Url-loader, similar to file loader but he can specify a limit parameter, when your file and picture is larger than your specified limit, it will be executed to file loader, when your file is less than limit It will automatically be converted into a base64 encoding.

11.image-webpack-loader Compress pictures, but must be used in conjunction with Url-loader or File-loader

Webpack working with resource files in a project

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.