Answer the question
In order to leave comments, you need to log in
Where to store common react components and how to include them?
The project has common components, connecting them via relative links: "../../../" is inconvenient.
Are there alternatives?
Answer the question
In order to leave comments, you need to log in
ну можно как вариант рассмотреть вынесение общих компонент в отдельный репозиторий и подключение его как npm пакет. Ну или да, как пишут выше, если дело только в путях
https://webpack.js.org/configuration/resolve/
+
https://github.com/timarney/react-app-rewired#how-...
+
https://www.npmjs.com/package/react -app-rewire-aliases
+ config-overrides.js
file (in the same place as package.json)
const rewireAliases = require("react-app-rewire-aliases");
const { paths } = require("react-app-rewired");
const path = require("path");
module.exports = function override(config, env) {
config = rewireAliases.aliasesOptions({
Views: path.resolve(__dirname, `${paths.appSrc}/templates/default/views`),
Components: path.resolve(__dirname, `${paths.appSrc}/controllers`),
Store: path.resolve(__dirname, `${paths.appSrc}/controllers/store`),
Config: path.resolve(
__dirname,
`${paths.appSrc}/controllers/services/Config`
),
})(config, env);
return config;
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question