小编Isi*_*oro的帖子

Bootstrap 图标和 Webpack 5 - 您可能需要适当的加载器来处理此文件类型

我在让 bootstrap 图标与 webpack 一起使用时遇到了很多麻烦:

得到以下内容:

ERROR in ./node_modules/bootstrap-icons/font/bootstrap-icons.css 1:0
Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @font-face {
|   font-family: "bootstrap-icons";
|   src: url("./fonts/bootstrap-icons.woff2?856008caa5eb66df68595e734e59580d") format("woff2"),
 @ ./src/index.js 3:0-50
Run Code Online (Sandbox Code Playgroud)

使用 webpack 规则:

      {
        test: /\.((png)|(eot)|(woff)|(woff2)|(ttf)|(svg)|(gif))(\?((v=\d+\.\d+\.\d+)|(\w*)))?$/,
        use: { loader: "file-loader?name=/[hash].[ext]" }
      },
      ...

      {
        test: /\.(sa|sc|c)ss$/,
        exclude: /node_modules/,
        use: [
          "style-loader",
          MiniCssExtractPlugin.loader,
          "css-loader",
          "postcss-loader",
          "sass-loader"
        ]
      }
Run Code Online (Sandbox Code Playgroud)

和 …

webpack bootstrap-icons

1
推荐指数
1
解决办法
6795
查看次数

标签 统计

bootstrap-icons ×1

webpack ×1