babel-plugin-webpack-chunkname

Automatically set the chunkname for dynamic imports

MIT 4 个版本
安装
npm install babel-plugin-webpack-chunkname
yarn add babel-plugin-webpack-chunkname
pnpm add babel-plugin-webpack-chunkname
bun add babel-plugin-webpack-chunkname
README

babel-plugin-webpack-chunkname

NPM version NPM downloads CircleCI donate chat

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

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. 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

版本列表
1.2.0 2018-05-17
1.1.0 2018-05-17
1.0.1 2017-12-28
1.0.0 2017-12-28