Can i remove / ignore files with a build command generated by webpack?

Viewed 48

I am using the wp-scripts package to generate some files. Internally wp-scripts uses webpack. The project is created using React and uses modular css.

package.json

"scripts": {
    ...
    "build": "wp-scripts build src/index.js src/save.js",
    ...
}

My package.json build command creates 3 files for every entry point.

current output

  • index.asset.php
  • index.js
  • index.css
  • save.asset.php
  • save.js
  • save.css

Only the css file of the save.js file is necessary. I don't want the other 2 files in the build.

desired output

  • index.asset.php
  • index.js
  • index.css
  • save.css

The question

So I want to remove 2 specific files.

Can someone explain how to:

  • not generate these 2 files in the build command ( preferred approach )
  • remove these 2 files after building them using the build command

NOTE: Currently I can either remove the files manually or keep them. It won't affect the project much. But I'd rather have it automated as I will probably forget to remove the files and make the build bigger than necessary.

0 Answers
Related