How to avoid using relative path imports (/../../../redux/action/action1) in create-react-app

前端 未结 7 599
太阳男子
太阳男子 2020-12-07 18:21

I\'ve been using create-react-app package for creating a react website. I was using relative paths throughout my app for importing components, resources, redux etc. eg,

相关标签:
7条回答
  • 2020-12-07 19:20

    in package.json file,

    eject this code in the scripts object like this..

      "scripts": {
        "start": "node scripts/start.js",
        "build": "node scripts/build.js",
        "test": "node scripts/test.js --env=jsdom",
         "eject": "NODE_PATH=src/ react-scripts eject"
      },
    

    this will enable the absolute path imports in your app

    0 讨论(0)
提交回复
热议问题