https://github.com/whtsky/babel-plugin-webpack-prefetch
https://github.com/whtsky/babel-plugin-webpack-prefetch
babel babel-plugin prefetch webpack webpack4
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/whtsky/babel-plugin-webpack-prefetch
- Owner: whtsky
- License: mit
- Created: 2018-04-23T05:32:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-11T19:26:28.000Z (11 months ago)
- Last Synced: 2025-04-11T20:30:59.798Z (11 months ago)
- Topics: babel, babel-plugin, prefetch, webpack, webpack4
- Language: JavaScript
- Size: 206 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-webpack-prefetch
Babel plugin for adding webpackPrefetch comment.
[](https://github.com/whtsky/babel-plugin-webpack-prefetch/blob/master/LICENSE)
[](https://www.npmjs.com/package/babel-plugin-webpack-prefetch)
[](https://travis-ci.org/whtsky/babel-plugin-webpack-prefetch)
[](https://codecov.io/gh/whtsky/babel-plugin-webpack-prefetch)
[](https://conventionalcommits.org)
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwhtsky%2Fbabel-plugin-webpack-prefetch?ref=badge_shield)
## Usage
```bash
yarn add -D babel-plugin-webpack-prefetch
```
then add `babel-plugin-webpack-prefetch` to your `.babelrc`
```diff .babelrc
{
"plugins": [
+ "babel-plugin-webpack-prefetch"
]
}
```
And it does :
```diff a.js
import ccc from 'ddd'
import 'aaa'
const a = import(
+ /* webpackPrefetch: true */
'aaa'
)
const b = import(
+ /* webpackPrefetch: true */
'bbb'
)
```
`babel-plugin-webpack-prefetch` will respect your comment :
```diff a.js
const a = import(
// you added webpackPrefetch: false so babel-plugin-webpack-prefetch will not modify it
/* webpackPrefetch: false */
'aaa'
)
const b = import(
+ /* webpackPrefetch: true */
'bbb'
)
```
## License
[](https://app.fossa.io/projects/git%2Bgithub.com%2Fwhtsky%2Fbabel-plugin-webpack-prefetch?ref=badge_large)