2

这是我第一个用作捆绑react器的项目parcel。在我开始集成之前,我一直喜欢开发服务器的速度和易用性react-css-modules。老实说,我不确定是什么导致了我的错误,所以这里的任何见解都将不胜感激。

在我的终端中,hot-module-replacement正在无错误地触发。保存任何更改时,我可以在几毫秒内重建我的应用程序。实际上,浏览器会更新对 css 的任何更改,但功能会因javascript错误而被杀死:

react-dom.development.js:15834 Uncaught TypeError: cb is not a function
    at react-dom.development.js:15834
    at Array.forEach (<anonymous>)
    at hmrAccept (react-dom.development.js:15833)
    at react-dom.development.js:15713
    at Array.forEach (<anonymous>)
    at WebSocket.ws.onmessage (react-dom.development.js:15710)

(anonymous) @ react-dom.development.js:15834
hmrAccept @ react-dom.development.js:15833
(anonymous) @ react-dom.development.js:15713
ws.onmessage @ react-dom.development.js:15710

我已经追溯到我的电话ReactDom.render()

我不确定这是否是我的配置错误,是否需要在github. 任何帮助表示赞赏。

index.js

import "babel-polyfill";
import React from 'react';
import * as ReactDOM from 'react-dom';
// cross-browser support for CSS variables
import cssVars from 'css-vars-ponyfill';
cssVars();

import './index.css';
import App from './Components/App'

const rootEntry = document.getElementById('form-root')
ReactDOM.render( <App/>, rootEntry);

.babelrc

{
    "plugins": [
        ["react-css-modules", {
            "generateScopedName": "[path]__[name]__[local]__[hash:base64:5]",
            "webpackHotModuleReloading": true,
            "handleMissingStyleName": "warn"
        }]
    ],
    "presets": [
        ["env", { "useBuiltIns": true }], "react"
    ]
}

.postcssrc

{
    "modules": true,
    "plugins": {
        "autoprefixer": {
            "browsers": [
                "Firefox >= 52",
                "Chrome >= 55",
                "ie >= 9",
                "last 4 versions",
                "Safari >= 9"
            ],
            "flexbox": "no-2009"
        },
        "postcss-modules": {
            "generateScopedName": "[path]__[name]__[local]__[hash:base64:5]",
            scopeBehaviour: 'local'
        }
    }
}
4

0 回答 0