babel-plugin-webpack-chunkname
v1.2.0
Published
Automatically set the chunkname for dynamic imports
Downloads
1,894
Readme
babel-plugin-webpack-chunkname
Install
yarn add babel-plugin-webpack-chunkname
Usage
With .babelrc
:
{
"plugins": [
"webpack-chunkname"
]
}
And it does this:
import('./pages/Home')
↓ ↓ ↓ ↓ ↓ ↓
import( /* webpackChunkName: 'pages/Home' */'./pages/Home')
And if you're using dynamic imports:
import(`./pages/${name}`)
↓ ↓ ↓ ↓ ↓ ↓
import( /* webpackChunkName: 'pages/[request]' */`./pages/${name}`)
Or using placeholder:
import(/* webpackChunkName: "__CHUNK_NAME__" */ `./foo`)
↓ ↓ ↓ ↓ ↓ ↓
import(/* webpackChunkName: "foo" */ `./foo`)
Options
getChunkName
- Type:
(imported: string) => string
- Default:
imported => imported.replace(/^[./]+|(\.js$)/g, '')
Contributing
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
babel-plugin-webpack-chunkname © EGOIST, Released under the MIT License. Authored and maintained by EGOIST with help from contributors (list).
egoist.moe · GitHub @EGOIST · Twitter @_egoistlily