Last active
December 3, 2020 16:45
-
-
Save james2doyle/97fe6eab114eee22fea4895bd0c44c6b to your computer and use it in GitHub Desktop.
A fastmod snippet that refactors module imports to dynamic imports with wepback chunking enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://github.com/facebookincubator/fastmod | |
# old code: `import MyComponent from 'Components/MyComponent.vue';` | |
# new code: `const MyComponent = () => import(/* webpackChunkName: "MyComponent" */ 'Components/MyComponent.vue');` | |
# note: you may need to reorder your imports when using a dynamic import | |
fastmod -m -d ./ --extensions vue \ | |
'import (.*?) from \'(.*?)\';' \ | |
'const ${1} = () => import(/* webpackChunkName: "${1}" */ \'${2}\');' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment