An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# [`babel-plugin-magic-comments`](https://www.npmjs.com/package/babel-plugin-magic-comments)

![CI](https://github.com/morganney/babel-plugin-magic-comments/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/morganney/babel-plugin-magic-comments/branch/main/graph/badge.svg?token=92J7AMZH8N)](https://codecov.io/gh/morganney/babel-plugin-magic-comments)
[![NPM version](https://img.shields.io/npm/v/babel-plugin-magic-comments.svg)](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`.