webpack loads css files and its configuration
const path = require('path'); module.exports = { // In the configuration file, manually specify the entry file and export file mode:'development', // This attribute needs to be added in the webpack4.x version entry:'./src/main.js', // Entry file output:{ // Export file path:path.resolve(__dirname,'dist'), // Specify where the packaged files should be output (note: the path must be an absolute address) filename: 'bundle.js' //Specify the file name of the output file}, module:{ rules:[ {test:/\.css$/ , use:['style-loader' , 'css-loader']} ] } } Test indicates what type of file we want to process, and each item in use is the loader required to process that type of file. Note: The css-loader is used to let the main.js file load the css file, while the style-loader is used to add the module's exports as styles to the DOM. Some people may have questions here: according to this function, the file should be loaded first and then added to the DOM as a style, so the order in the array should not be like this. I am here to tell you clearly that your idea is not wrong, but webpack is very peculiar in that it loads the loader from the last element of the array, from right to left. After setting the dependency, downloading the loader and configuring it, we will find that the styles in the CSS file appear after running it. Summarize The above is the webpack loading css file and its configuration method introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you! |
<<: How to use Element in React project
>>: Pagination Examples and Good Practices
Table of contents 1. Backup 1.1 Fully prepared 1....
I think the carousel is a relatively important po...
Preface The role of process management: Determine...
Copy code The code is as follows: <!DOCTYPE ht...
Table of contents 1. The concept of process and t...
Docker is an open source project that provides an...
Table of contents 1. Class 1.1 constructor() 1.2 ...
Image tag : <img> To insert an image into a ...
Overview As for the current default network of Do...
First, download the installation package from the...
Preface In the process of writing code, we will i...
First query table structure (sys_users): SELECT *...
Adding the right VS Code extension to Visual Stud...
Table of contents introduce Object attributes in ...
The two parameters innodb_flush_log_at_trx_commit...