我正在做一个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>
我不了解webpack
我已经设置了customize-cra
,并拥有config-override.js
文件。
module.exports = function override(config, env) {
// do stuff with the webpack config...
return config;
};