config-overrides配置outputDir
时间: 2023-12-10 10:02:51 浏览: 91
config-overrides.js 是一个用于修改 create-react-app 默认配置的文件。如果你想要修改输出目录(outputDir),你可以按照以下步骤进行操作:
1. 在项目根目录下创建一个 config-overrides.js 文件。
2. 添加以下代码:
```javascript
const paths = require('react-scripts/config/paths');
module.exports = function override(config, env) {
// 修改输出路径
paths.appBuild = path.join(path.dirname(paths.appBuild), 'your-custom-dir-name');
config.output.path = paths.appBuild;
return config;
};
```
3. 将 "build" 脚本修改为 "react-scripts build --config-overrides.js"。
4. 运行 "npm run build" 命令,输出目录将会被修改为 "your-custom-dir-name"。
注意:这种修改方式可能会导致一些不可预料的问题,因此建议仔细考虑是否需要修改输出目录。
相关问题
选项--targets FILENAME--non-recursive (-N)--quiet (-q)--config-dir DIR--no-ignore--auto-props--no-auto-props--force
The provided options appear to be related to a command-line utility or tool that likely has flags for various functionalities. Here's a brief explanation of each option:
1. `--targets FILENAME`: This flag specifies a file containing a list of targets for the tool to operate on. It allows you to input multiple targets from a single external file.
2. `--non-recursive (-N)`: If included, the tool will not perform actions recursively; it will only act on the specified targets directly, not any subdirectories.
3. `--quiet (-q)`: This flag requests a quieter output, which might mean suppressing some messages or reducing the verbosity of the tool's output.
4. `--config-dir DIR`: Specifies the directory where configuration files are stored, allowing the tool to read and use settings from that location.
5. `--no-ignore`: By default, the tool might ignore certain patterns or files. This flag disables that behavior, making it process everything without ignoring specific items.
6. `--auto-props`: Enables automatic property detection or generation, likely for files that support metadata or custom properties.
7. `--no-auto-props`: If present, overrides the automatic property detection, forcing the tool to not use any detected properties.
8. `--force`: This flag usually implies that the tool should proceed with its action even if there are potential conflicts or existing changes that could be overwritten.
To use these options in a command, they would typically be appended to the command name, like this:
```
tool --targets mytargets.txt --non-recursive -q --config-dir /path/to/config --no-ignore --auto-props --force
```
However, without knowing the specific tool, it's difficult to provide a demonstration. The actual syntax and behavior may vary depending on the tool in question.
阅读全文