简体   繁体   中英

how to use 'include' option for webpack loader correctly

There is the following loader config:

{
    test: /\.(png|svg)$/,
    include: projectBasePath + '/src/app/assets/images/favicons',
    loader: 'file?name=' + defaultPublicImagesPath + 'favicons/' + '[name].[ext]'
  }

projectBasePath and defaultPublicImagesPath are some path variables, there are no mistakes in them. There is some file which requires images:

require('app/assets/images/favicons/favicon-16x16.png');
require('app/assets/images/favicons/favicon-32x32.png');

require('app/assets/images/favicons/apple-touch-icon.png');

require('app/assets/images/favicons/safari-pinned-tab.svg');

require('app/assets/images/favicons/android-chrome-192x192.png');

require('app/assets/images/favicons/mstile-70x70.png');
require('app/assets/images/favicons/mstile-144x144.png');
require('app/assets/images/favicons/mstile-150x150.png');
require('app/assets/images/favicons/mstile-310x150.png');
require('app/assets/images/favicons/mstile-310x310.png');

But when I try to make a build with webpack I get error that there is not loader for these images. How can I fix it?

You need to install the file loader for webpack to use it. Install it using this command:

npm install file-loader --save-dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM