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

215
Views
Remove js and css scripts based on pattern using webpack 5

Does anyone know of something similar to the below webpack plugin but compatible with webpack 5?

https://www.npmjs.com/package/html-webpack-plugin-remove

I simply need to remove scripts and css that follow a certain pattern but using a webpack 5 build.

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

0

In Webpack 5, on-build-webpack plugin did not work for me.

I found this:

Webpack Shell Plugin Next

In the project I’m working on we’re using Webpack 5 as a build tool for a CSS pattern library. Therefore, we didn’t need the main.js in our dist.

Run npm i -D webpack-shell-plugin-next

Then in webpack.config.ts (just showing the pertinent parts):

import WebpackShellPluginNext from "webpack-shell-plugin-next";

module.exports = {
    output: {
        path: path.resolve(__dirname, "static/dist")
    },
    plugins: [
        // Run commands before or after webpack 5 builds:
        new WebpackShellPluginNext({
            onBuildEnd: {
                scripts: [
                    () => {
                        fs.unlinkSync(path.join(config.output.path, "main.js"));
                    }
                ]
            }
        })
    ]
};

export default config;
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!