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

172
Views
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 answers
Answer question

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 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!