**Error con Dev Middleware **
- ValidationError: Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema.
- options has an unknown property ‘hot’. These properties are valid:
object { mimeTypes?, writeToDisk?, methods?, headers?, publicPath?, serverSideRender?, outputFileSystem?, index? }
-ValidationError: Invalid options object. Dev Middleware has been initialized using an options object that does not match the API schema. - options has an unknown property ‘port’. These properties are valid: object { mimeTypes?, writeToDisk?, methods?, headers?, publicPath?, serverSideRender?, outputFileSystem?, index? }
Con la instalación de:
npm install webpack-dev-middleware webpack-hot-middleware react-hot-loader
Con la siguiente configuración en el package.json
"dependencies": {
"@babel/register": "^7.12.1",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"md5": "^2.3.0",
"nodemon": "^2.0.6",
"prop-types": "^15.7.2",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-hot-loader": "^4.13.0",
"react-redux": "^7.2.1",
"react-router-dom": "^5.2.0",
"redux": "^4.0.5",
"webpack": "^5.4.0",
"webpack-dev-middleware": "^4.0.0",
"webpack-hot-middleware": "^2.25.0"
},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.5",
"@babel/runtime": "^7.12.5",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"css-loader": "^4.3.0",
"eslint": "^7.13.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"file-loader": "^6.2.0",
"html-loader": "^1.3.2",
"html-webpack-plugin": "^4.5.0",
"mini-css-extract-plugin": "^1.3.0",
"node-sass": "^4.14.1",
"sass-loader": "^10.0.5",
"webpack-cli": "^4.2.0",
"webpack-dev-server": "^3.11.0"
}
Colocar el siguiente codigo en el server.js
if (config.env === 'development') {
console.log('Development config');
const webpackConfig = require('../../webpack.config');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const compiler = webpack(webpackConfig);
const { publicPath } = webpackConfig.output;
const serverConfig = { serverSideRender: true, publicPath };
app.use(webpackDevMiddleware(compiler, serverConfig));
app.use(webpackHotMiddleware(compiler));
}
Con el codigo en el .babelrc
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
"@babel/plugin-proposal-class-properties",
// para que acepte async/ await
"@babel/plugin-transform-runtime",
"react-hot-loader/babel"
]
}
Me sale el siguiente mensaje
Server running on port: 3000
(node:22292) [DEP_WEBPACK_COMPILATION_ASSETS] DeprecationWarning: Compilation.assets will be frozen in future, all modifications are deprecated.
BREAKING CHANGE: No more changes should happen to Compilation.assets after sealing the Compilation.
Do changes to assets earlier, e. g. in Compilation.hooks.processAssets.
Make sure to select an appropriate stage from Compilation.PROCESS_ASSETS_STAGE_*.
webpack built 9eb60c02b6e910dda0fd in 4787ms
Al parecer todo funciona bien solamente no se si ese mensaje afecte a futuro si alguien ha logrado solucionarlo agradecería que me ayudaran, gracias de antemano
¿Quieres ver más aportes, preguntas y respuestas de la comunidad?
o inicia sesión.