我可以使用 webpack 生成的构建命令删除/忽略文件吗?
我正在使用 wp-scripts
包 生成一些文件。 wp-scripts
内部使用 webpack
。该项目是使用 React 创建的,并使用模块化 css。
package.json
"scripts": {
...
"build": "wp-scripts build src/index.js src/save.js",
...
}
我的 package.json 构建命令为每个入口点创建 3 个文件。
当前输出
- index.asset.php
- index.js
- index.css
- save.asset.php
- save.js
- save.css
仅需要save.js
文件的css文件。我不想要构建中的其他 2 个文件。
所需输出
- index.asset.php
- index.js
- index.css
- save.css
问题
所以我想删除2个特定文件。
有人可以解释一下如何:
- 不在构建命令中生成这两个文件(首选方法)
- 在使用构建命令构建这两个文件后删除它们
注意:目前我可以手动删除这些文件或保留它们。不会对项目造成太大影响。但我宁愿让它自动化,因为我可能会忘记删除文件并使构建变得比必要的更大。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论