webpack 问题
1 TypeError: this.htmlWebpackPlugin.getHooks is not a function
- 方案一:
npm i --save html-webpack-plugin@next
- 参考方案:
https://github.com/facebook/create-react-app/issues/5465
2 css 分离
extract-text-webpack-plugin 暂时还不能webpack4版本 解决办法
方案一(推荐):
使用 mini-css-extract-plugin 替代 extract-text-webpack-plugin
- 好处:
- 异步加载
- 不重复编译,性能更好
- 更容易使用
- 只针对CSS
方案二:
npm i --save-dev extract-webpack-plugin@next
TS 问题
findDOMNode 在ts 中使用
比如获取图片 Property 'src' does not exist on type 'ChildNode'.ts(2339)
const imgNode = findDOMNode(this).firstChild
console.log(imgNode.src)
解决方案:
const imgNode = findDOMNode(this).firstChild as HTMLImageElement