字体Loader

选择一种字体

大部分浏览器支持.woff格式字体,除Opera Mini,所以如果不需要支持Opera,则:

  1. {
  2. test: /\.woff$/,
  3. loader: 'url?limit=50000',
  4. include: PATHS.fonts
  5. }
  1. // 支持woff2格式
  2. {
  3. // Match woff2 in addition to patterns like .woff?v=1.1.1.
  4. test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  5. loader: 'url',
  6. query: {
  7. limit: 50000,
  8. mimetype: 'application/font-woff',
  9. name: './fonts/[hash].[ext]'
  10. }
  11. }

多字体支持

  1. {
  2. test: /\.woff$/,
  3. // Inline small woff files and output them below font/. ,Set mimetype just in case.
  4. loader: 'url',
  5. query: {
  6. name: 'font/[hash].[ext]',
  7. limit: 5000,
  8. mimetype: 'application/font-woff'
  9. },
  10. include: PATHS.fonts
  11. },
  12. {
  13. test: /\.ttf$|\.eot$/,
  14. loader: 'file',
  15. query: {
  16. name: 'font/[hash].[ext]'
  17. },
  18. include: PATHS.fonts
  19. }

<<上一节:图片Loader >>下一节:理解Chuncks