score:0
webpack provides a module resolve functionality that you can use here. read the docs here. as an example, in your case, you can do this:
const path = require('path');
module.exports = {
resolve: {
alias: {
'@/components/module1': path.join(
__dirname,
process.env.app_brand
? '@/components/brands/' + process.env.app_brand + 'module1'
: '@/components/module1')
}
},
};
note that, here you would pass environment variable to your webpack process (aka node.js process) and make decision accordingly. also, your resolve module must be absolute path.
Source: stackoverflow.com
Related Query
- Is it possible to resolve imported module path at compile time in Webpack?
- Module not found: Error: Can't resolve FILE in PATH - Webpack or Babel issue
- Bundle error using webpack for Electron application `Cannot resolve module 'electron'`
- Unable to resolve path to module 'react'. (import/no-unresolved)
- eslint + typescript + path in tsconfig: ESLint: Unable to resolve path to module '@components/some-module'.(import/no-unresolved)
- eslint imports in webpack: Unable to resolve path to module
- Webpack and TypeScript: Cannot resolve module 'child_process' in node.d.ts
- Webpack - How to resolve module recursively
- Unable to resolve path to module '@aws-amplify/ui-react/styles.css'
- TypeError: Webpack imported module is not a function
- Module not found: Error: Cannot resolve module 'react' when I use webpack
- Resolve Relative Path from node_modules to Dist folder with Webpack
- React native Typescript path alias unable to resolve module
- Unable to resolve path to module '@nivo/pie'
- Images in React: is it possible to use a string from an imported object as the source path for an image?
- Next.js + eslint: unable to resolve path to module 'fs/promises'
- Module not found: Error: Cannot resolve module 'components/app'. webpack + reactjs issue
- Evaluate conditionals at compile time in babel / webpack
- webpack config error of cannot resolve module
- Unable to compile using Material-UI: Module not found: Can't resolve '@babel/runtime/core-js/object/get-prototype-of'
- Webpack JSX cannot resolve relative module through ES6 imports
- eslint: Unable to resolve path to module 'src/interfaces'
- Webpack can't resolve relative path import express static
- Is it possible to dynamically change image resource path in webpack based on node.js environment
- Custom webpack configuration: Module not found: Error: Can't resolve 'react-dom/client' in 'D:\web development\react\webpack-react-boilerplate\src'
- Module not found: Error: Can't resolve ' ' when trying to run webpack
- My Webpack configuration for React 18 shows Uncaught TypeError: Failed to resolve module specifier "react-dom/client"
- webpack Module not found: Error: Can't resolve classNames
- Failed to compile ./src/App.js Module not found: Can't resolve 'firebase'
- React App failed to compile - Module not found: Can't resolve 'react'
More Query from same tag
- React, Should I set state from props?
- onmouseover show Message on React
- In React, how can I create a flexible array of selected items, using checkboxes, similar to selecting images on my Phone?
- How to add linear-gradient color to MUI Chip background?
- How can display data fetched from an api properly in react?
- Elasticsearch query to return those documents also which are missing an indexed value
- Sharing a JavaScript class across multiple React components
- Why is portalcontent not injected?
- React Js front end and Express backend - can't load static files properly
- How to construct an Array to first compare and then add the input
- How to format and display JSON data using Array.map in Reactjs?
- React Native / Redux - setState - Cannot update during an existing state transition
- How to test a react component properly?
- typescript failed to infer destructuring array type in custom hook
- How to deploy a reactJS application to Heroku
- `setNum(() => num++)` not working, but `setNum(() => num + 1)`
- react rollup no styling with tailwind css and css
- How to make the text inside div stick to the left?
- Pass an Array of known shape but unknown size to component?
- How to use .dispatch in react redux?
- How to disable react-hooks/exhaustive-deps eslint warning globally?
- Multiple queries error in Gatsby "Multiple "root" queries found"
- How to get value of button on button click in node js?
- How can I refactor this if statement? (React)
- React.js 16.8.0 to 18.1.0 Transformation
- Can't apply styles to Textfield using className in materi-ui latest version V1.0.0-beta.26
- Need help printing out a list from db
- How we can give type to react element using TSX
- Confusion about how to add submodule in Git
- React Admin Confirmation Dialogue On Save