我在让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有了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"
]
}和.js as
import "./scss/main.scss";
import "bootstrap-icons/font/bootstrap-icons.css";能找到的我都试过了。我跟踪了这段代码的每一行,但仍然不能让它工作:https://odan.github.io/2021/01/07/webpack-bootstrap-icons.html
webpack: "5.52.1",
"bootstrap-icons": "^1.5.0",
"file-loader": "^6.2.0",发布于 2021-09-18 16:37:30
我也有同样的问题,我通过阅读documentation解决了这个问题。后来我发现的问题是,webpack不会用purgecss清除bootstrap中不常见的图标。
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: "asset/inline",
},https://stackoverflow.com/questions/69208829
复制相似问题