babel-alias-quokka-plugin
v1.0.9
Published
Resolves imports on the basis of a .babelrc or custom config
Downloads
799
Readme
babel-alias-quokka-plugin
Quokka plugin to enable babel aliases that have been loaded with babel-plugin-module-resolver
.
(these are not required, though, and aliases can be defined at the quokka.alias
path of package.json
.)
It uses babel-load-config
to find the babel config.
It then uses it to configure a module resolver from babel-plugin-module-resolver
and uses that to resolve modules for Quokka.
Installation:
yarn add babel-alias-quokka-plugin
Then ensure this is in the top level of your package.json
"quokka": {
"babel": true, // needed for imports
"plugins": ["babel-alias-quokka-plugin"],
}
Aliases can either be pulled out of the configuration of babel-plugin-module-resolver
automatically or you can specify them in package.json
(see below)
Example Usages
Via Babel config:
{
"plugins": [
[
"module-resolver",
{
"root": ["./"],
"alias": {
"test": "./test"
}
}
]
]
}
Via package.json
:
"quokka": {
"babel": true,
"plugins": ["babel-alias-quokka-plugin"],
"alias": {
"test": "./test"
}
}
Testing
To test, open test/index.js
in VSCode and start Quokka