The create-react-app imports restriction outside of src directory

前端 未结 17 1895
时光说笑
时光说笑 2020-11-22 13:20

I am using create-react-app. I am trying to call an image from my public folder from a file inside my src/components. I am receiving this error message.

17条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-22 13:54

    Remove it using Craco:

    module.exports = {
      webpack: {
        configure: webpackConfig => {
          const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
            ({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin'
          );
    
          webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
          return webpackConfig;
        }
      }
    };
    

提交回复
热议问题