https://github.com/morganney/babel-plugin-magic-comments
Adds webpack magic comments to your dynamic imports.
https://github.com/morganney/babel-plugin-magic-comments
babel-plugin magic-comments webpack
Last synced: 4 months ago
JSON representation
Adds webpack magic comments to your dynamic imports.
- Host: GitHub
- URL: https://github.com/morganney/babel-plugin-magic-comments
- Owner: morganney
- License: mit
- Created: 2023-07-01T20:50:34.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-01T03:31:34.000Z (almost 2 years ago)
- Last Synced: 2025-10-10T06:36:49.993Z (9 months ago)
- Topics: babel-plugin, magic-comments, webpack
- Language: JavaScript
- Homepage:
- Size: 256 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [`babel-plugin-magic-comments`](https://www.npmjs.com/package/babel-plugin-magic-comments)

[](https://codecov.io/gh/morganney/babel-plugin-magic-comments)
[](https://www.npmjs.com/package/babel-plugin-magic-comments)
Babel plugin to add webpack [magic comments](https://webpack.js.org/api/module-methods/#magic-comments) to your dynamic `import()` expressions at build time.
## Getting Started
First install `babel-plugin-magic-comments`:
```
npm install babel-plugin-magic-comments
```
Next add the plugin to your `babel.config.js`:
```js
export default () => {
return {
plugins: [
['magic-comments', {
verbose: true,
webpackChunkName: true,
webpackFetchPriority: "high"
}]
]
}
}
```
Or include it directly in your `webpack.config.js`:
```js
module: {
rules: [
{
test: /\.[jt]sx?$/,
use: {
loader: 'babel-loader',
options: {
plugins: [
['magic-comments', {
verbose: true,
webpackChunkName: true,
webpackFetchPriority: "high"
}]
]
}
}
}
]
}
```
## Options
The options are the same as those used by [`magic-comments-loader`](https://github.com/morganney/magic-comments-loader#options), with the exception of `mode` (not supported).
## Examples
For some more usage examples you can check out the ones provided by [`magic-comments-loader`](https://github.com/morganney/magic-comments-loader#examples), particularly the loader's `options`.