如何使用'包括' webpack loader的选项正确

时间:2016-11-12 09:47:41

标签: javascript webpack

有以下加载程序配置:

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

projectBasePathdefaultPublicImagesPath是一些路径变量,它们中没有错误。有一些文件需要图像:

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');

但是当我尝试使用webpack进行构建时,我得到的错误是这些图像没有加载器。我该如何解决?

1 个答案:

答案 0 :(得分:-1)

您需要安装webpack的文件加载器才能使用它。使用以下命令安装它:

npm install file-loader --save-dev