這個問題是從 Webmasters Stack Exchange
module: {
rules: [
{
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
},
],
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.(?:ico|gif|png|jpg|jpeg|xml)$/i,
type: 'asset/resource',
},
{
test: /\.xml/,
type: 'asset/resource',
generator: {
filename: 'sitemap.xml',
},
},
{
test: /\.txt/,
type: 'asset/resource',
generator: {
filename: 'robots.txt',
},
},
{
test: /\.(woff(2)?|eot|ttf|otf|svg|)$/,
type: 'asset/inline',
},
],
},
最后確保您將該檔案匯入到您的反應應用程式中,否則它將不會用于構建檔案夾

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/425758.html
上一篇:當Javascript創建相對影像URL時,Webpack不會保存影像,但當HTML中存在相同的相對影像URL時會保存它們
