我正在尝试使用react-snap
插件将页面上的 html 呈现为源代码,并在其中进行以下配置package.json
包.json
{
..//
"scripts": {
"test": "jest",
"coverage": "jest --coverage",
"build:prod": "rm -rf dist && webpack --mode production --config webpack.prod.js",
"start:dev": "rm -rf dist && webpack-dev-server --mode development --config webpack.dev.js",
"postbuild": "react-snap"
},
"reactSnap": {
"source": "dist",
"inlineCss": true,
"removeBlobs": true,
"removeScriptTags": true,
"removeStyleTags": true,
"minifyHtml": {
"collapseWhitespace": false,
"removeComments": false
}
},
..//
}
index.js
import { hydrate, render } from "react-dom";
const rootElement = document.getElementById("root");
if (rootElement.hasChildNodes()) {
hydrate(<App />, rootElement);
} else {
render(<App />, rootElement);
}
但它根本不起作用,请帮助