Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
¿Cómo escribo la salida en un archivo usando Webpack?

Estoy tratando de escribir la salida en el archivo mientras uso Dev-server pero recibí un error que dice:

 been initialized using a configuration object that does not match the API schema. - configuration has an unknown property 'devMiddleware'. These properties are valid: object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, experiments?, externals?, externalsPresets?, externalsType?, ignoreWarnings?, infrastructureLogging?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, snapshot?, stats?, target?, watch?, watchOptions? } -> Options object as provided by the user. For typos: please correct them. For loader options: webpack >= v2.0.0 no longer allows custom properties in configuration. Loaders should be updated to allow passing options via loader options in module.rules. Until loaders are updated one can use the LoaderOptionsPlugin to pass these options to the loader: plugins: [ new webpack.LoaderOptionsPlugin({ // test: /\.xxx$/, // may apply this only for some modules options: { devMiddleware: … } }) *

Aquí está mi webpack.config.js :

 const path = require('path'); module.exports={ mode:"development", entry:'./src/app.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'output.js' }, module: { rules: [ { test: /\.css$/, use:['style-loader','css-loader'] } ], }, devServer: { static: { directory: path.join(__dirname, './dist'), }, compress: true, port: 3200 }, devMiddleware: { writeToDisk: true, } }

y aquí está paquete.json

 { "name": "new-folder", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "build": "webpack", "start": "webpack-dev-server --mode development --open" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "web-cli": "^1.0.0-prealpha", "webpack": "^5.72.1" }, "devDependencies": { "css-loader": "^6.7.1", "style-loader": "^3.3.1", "webpack-cli": "^4.9.2", "webpack-dev-middleware": "^5.3.3", "webpack-dev-server": "^4.9.0" } }

por favor alguien ayuda

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Mueva su configuración de middleware dentro del objeto de configuración devServer como se muestra a continuación:

 const path = require('path'); module.exports = { mode:'development', entry:'./src/app.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'output.js' }, module: { rules: [ { test: /\.css$/, use:['style-loader','css-loader'] } ], }, devServer: { static: { directory: path.join(__dirname, './dist'), }, compress: true, port: 3200, devMiddleware: { writeToDisk: true } } }

Además, en teoría, no debería necesitar usar writeToDisk . Debe tener un comando de compilación separado que genere una compilación de producción que escribiría en el disco. Por ejemplo, tendría el siguiente objeto de secuencia de comandos npm:

 // package.json { "scripts": { "start": "webpack serve", "build": "webpack" } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!