Storybook + Font Files

I can't get Storybook webpack to compile my CSS. He throws up font files and tells me that I may need a bootloader, but I added it to the file webpack.config.jsthat it uses.

Here is mine webpack.config.js:

const resolve = require('path').resolve;

module.exports = {
  module: {
    loaders: [
      {
        test: /\.css$/,
        loaders: ['style', 'css', 'postcss?modules'],
        include: resolve(__dirname, '../')
      },
      {
        test: /\.(png|woff|woff2|eot|ttf|svg)$/,
        loaders: ['file'],
        include: resolve(__dirname, '../')
      }
    ]
  }
};

I have a bootloader and it sees it, but it still gives me errors like this:

ERROR in ./~/font-awesome/fonts/fontawesome-webfont.svg?v=4.7.0
Module parse failed: /home/dcpdev/projects/my-project/node_modules/font-awesome/fonts/fontawesome-webfont.svg?v=4.7.0 Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (1:0)
    at Parser.pp$4.raise (/home/dcpdev/projects/my-project/node_modules/webpack/node_modules/acorn/dist/acorn.js:2221:15)
    at Parser.pp.unexpected (/home/dcpdev/projects/my-project/node_modules/webpack/node_modules/acorn/dist/acorn.js:603:10)
    at Parser.pp$3.parseExprAtom (/home/dcpdev/projects/my-project/node_modules/webpack/node_modules/acorn/dist/acorn.js:1822:12)
    <snip>

I get one of these errors for each extension (eot, woff, woff2, ttf, svg).

I know that he is reading this file webpack.config.js, because if I something like changing the name of the meaningless bootloader (for example cake), I get an error from it.

In addition, the file is located in the directory storybookfrom the root of my project, so it resolve(__dirname, '../')should put it in the root of my project.

What am I missing?

+4
1

3 , ?

, webpack.config.js, , :

{
    test: /\.(png|woff|woff2|eot|ttf|svg)$/,
    loaders: ['file-loader'],
    include: path.resolve(__dirname, '../')
}

, -, .

+2

Source: https://habr.com/ru/post/1677472/


All Articles