Skip to content

Latest commit

 

History

History
27 lines (23 loc) · 655 Bytes

FAQ.md

File metadata and controls

27 lines (23 loc) · 655 Bytes

FAQ

如何引入src文件夹外的文件?

which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.

如上由于使用create-react-app后不能引入src文件夹外的文件。

解决方案为: 借助react-app-rewired重写webpack配置。

npm i --save-dev react-app-rewired customize-cra

修改package.json

"scripts": {
-  "start": "react-scripts start"
+  "start": "react-app-rewired start",
},

根目录下新建config-overrides.js

const { removeModuleScopePlugin } = require('customize-cra')

module.exports = removeModuleScopePlugin()