Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack NormalModuleReplacementPlugin with jest #136

Open
gloriaJun opened this issue Jan 14, 2022 · 0 comments
Open

webpack NormalModuleReplacementPlugin with jest #136

gloriaJun opened this issue Jan 14, 2022 · 0 comments
Assignees

Comments

@gloriaJun
Copy link
Owner

gloriaJun commented Jan 14, 2022

webpack.config.js

new webpack.NormalModuleReplacementPlugin(/\.\/config-APPLICATION_PHASE/, `./config-${config.build.phase}`),

config dir

╰─❯ ls -al src/config 
total 64
drwxr-xr-x  10 user  staff  320  1 14 11:24 .
drwxr-xr-x  18 user  staff  576  1  4 21:01 ..
-rw-r--r--   1 user  staff  503  1 14 11:33 config-APPLICATION_PHASE.ts
-rw-r--r--   1 user  staff  981  1 14 11:24 config-BETA.js
-rw-r--r--   1 user  staff  220  1 14 11:24 config-LOCAL.js
-rw-r--r--   1 user  staff  830  1 14 11:24 config-REAL.js
-rw-r--r--   1 user  staff  209  1 14 11:24 index.ts

jest.config.js

to read phaseConfig on jest env

// jest.config.js
moduleNameMapper: {
    // ...SKIP...
    '^./config-APPLICATION_PHASE$': '<rootDir>/src/config/config-BETA',
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant