Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda