[英]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. projectBasePath
和defaultPublicImagesPath
是一些路径变量,它们中没有错误。 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. 但是,当我尝试使用webpack进行构建时,出现错误,提示这些图像没有加载程序。 How can I fix it? 我该如何解决?
You need to install the file loader for webpack to use it. 您需要为webpack安装文件加载器才能使用它。 Install it using this command: 使用以下命令安装它:
npm install file-loader --save-dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.