babel-plugin-webpack-prefetch

babel plugin for adding webpackPrefetch comment

MIT License

Downloads
12
Stars
4

babel-plugin-webpack-prefetch

Babel plugin for adding webpackPrefetch comment.

Usage

yarn add -D babel-plugin-webpack-prefetch

then add babel-plugin-webpack-prefetch to your .babelrc

{
  "plugins": [
+    "babel-plugin-webpack-prefetch"
  ]
}

And it does :

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 :

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