Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

174
Vistas
Avoid downloading empty JavaScript file when using MiniCssExtractPlugin and async chunks

When using async chunks with MiniCssExtractPlugin, an empty JavaScript file is created. This file is downloaded together with the extracted CSS file. Is there any way to avoid this, i.e. download only the CSS file?

// index.js
const styles = () => import(/* webpackChunkName: "hello" */ "./hello.less);
// webpack.config.js
return {
  ...
  module: {
    rules: [
      {
        test: /\.less$/i,
        use: [MiniCssExtractPlugin.loader, "css-loader", "less-loader"]
      }
    ]
  }
};

If I call styles() both hello.js and hello.css are downloaded (the latter is injected in head)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To generate the CSS file only, without empty JS file, use the webpack plugin webpack-remove-empty-scripts.

Install the plugin:

npm install webpack-remove-empty-scripts --save-dev

Add to webpack.config.js following:

const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');

return {
  ...
  plugins: [
    new RemoveEmptyScriptsPlugin(),
    ...
  ]
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda