1.2.0 • Published 6 years ago

babel-plugin-webpack-chunkname v1.2.0

Weekly downloads
716
License
MIT
Repository
github
Last release
6 years ago

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