- Learn loader
loader make webpack able to deal with those non-JavaScript files (webpack itself only understand JavaScript). loader can convert all types of files is valid module webpack can handle, then you can use packaged ability webpack, and to process them.
2. Install loader
Mounting style-loader and css-loader
download:
npm install style-loader css-loader --save-dev
3. Configure loader
(1) The rules in the configuration module webpack.config.js file
In webpack configuration loader has two objectives:
1. test attributes that should be used to identify the corresponding loader or for a certain file conversion.
2. use when attribute indicates the conversion, which should loader use.
Code:
4. Create css file and run the command
Creating index.css file and import the file into index.js