Created
January 22, 2019 12:04
-
-
Save matheus1lva/efe46c74f0e8b681a9402a144195734a to your computer and use it in GitHub Desktop.
code splitting/dynamic import
This file contains hidden or 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
// generates a single file for your component.js | |
// only when used. | |
// This returns a promise, which needs to be resolved. | |
import('./components/component.js') | |
// creates a chunk for each file inside your components folder | |
// This is called require context (which require.context is used under the hood) | |
// Webpack is smart enough to do that for you! | |
const myComponents = (componentName) => import(`./components/${componentName}.js`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment