reactjs - custom-cra 缩小 CSS 并将其嵌入 HTML
问题描述
我正在做一个 React 项目。我希望我的 CSS 嵌入到 HTML 本身中,而不需要对 CSS 进行网络调用。
CSS
body{
background-color: #000000;
}
到一个文件中
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>React App</title>
<style>
body{
background-color: #000000;
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
我不知道我已经设置customize-cra
并有config-override.js
文件的 webpack。
module.exports = function override(config, env) {
// do stuff with the webpack config...
return config;
};
解决方案
可能这就是你需要的“react-style-tag”
从您的帖子中,我认为您希望将样式包含在 index.html 文件中
推荐阅读
- python - Azure 函数列表操作显示索引超出范围
- python - 气流-('连接中断:IncompleteRead(0字节读取)',IncompleteRead(0字节读取))
- firebase - Firebase:更新数据时避免读取
- postgresql - 从视图中选择时 Postgres 崩溃
- eclipse - Eclipse 中的 Github 设置(Sage X3)
- javascript - Javascript 轮播动画
- sqlite - 无法使用 sqlite 和 clojurescript 支持创建 luminus 项目
- oracle - Oracle SQL如何让数据库计算一列?
- ruby-on-rails - 导轨。在一个事务中创建一个对象及其关联
- javascript - 尝试使用 dropzone 返回值时出错