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

202
Views
Webpack 5 IgnorePlugin - Not ignoring JS file from output on CSS files only?

I am trying to use the Webpack's IngorePlugin. I am using my Webpack file only to create a CSS file. On build, it outputs a JS file. But I don't want that. Tried ignoring JS files but still outputs it.

new webpack.IgnorePlugin(/^\.\/js\/(?!admin)/),

Outputs in the ROOT folder. So I want to disable all JS files from the output in the root folder. "admin" is the file being created.

How can I do this?

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

0

To properly answer your question, it'd be helpful if you posted a link to the full WP config file and an example of the file that's being processed.

Also, you mentioned you're only using WP to create a CSS file, does that mean you're just trying to use something like SASS, Stylus, Less, etc? If so, you could probably just set up a package.json script to compile your CSS without WP.
For example, if you have a .scss file, you could install node-sass, and create a simple Node script to compile what file you pass in as an arg.

bin/
  - build-css.js
src/
  - styles.sass

Within build-css.js

#!/usr/bin/env node

const { basename, resolve } = require('path');
const sass = require('node-sass');

const [...files] = process.argv.slice(2);

if (files.length) {
  files.forEach((relativeFilePath) => {
    const fileName = basename(relativeFilePath, '.scss');
    
    sass.render(
      {
        file: resolve(__dirname, relativeFilePath),
        outFile: resolve(__dirname, `./public/css/${fileName}.css`),
      },
      (err, result) => { console.log(err); }
    );
  });
}
else {
  console.log('No files were provided to process');
}

Within package.json

"scripts": {
  "build:css": "node ./bin/build-css.js"
}

The above has the benefit of giving you the control of how your files are processed at a more granular level, and you're only locked in to any SCSS changes, instead of Webpack and SCSS.

If you're using WP for it's file watching capabilities, you could instead wire up chokidar to run the new script when you change files.

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!