How to load image files with webpack file-loader

后端 未结 6 1951
[愿得一人]
[愿得一人] 2020-11-27 09:13

I am using webpack to manage a reactjs project. I want to load images in javascript by webpack file-loader. Below is the

6条回答
  •  心在旅途
    2020-11-27 09:41

    Install file loader first:

    $ npm install file-loader --save-dev
    

    And add this rule in webpack.config.js

               {
                    test: /\.(png|jpg|gif)$/,
                    use: [{
                        loader: 'file-loader',
                        options: {}
                    }]
                }
    

提交回复
热议问题