Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@clair/babel-plugin-inject-style
Advanced tools
When import a given component, import its corresponding style file automatically.
When import a given component, import its corresponding style file automatically.
npm i -D @clair/babel-plugin-inject-style
# or
yarn add -D @clair/babel-plugin-inject-style
In your babel-config.js
or .babelrc
module.exports = {
plugins: ['@clair/inject-style'] // or '@clair/babel-plugin-inject-style'
}
By default, it is designed to be used with @clair/vue
and @clair/react
.
But certain flexibility can be achieved by options
Default: '@clair/vue
.
To specify which UI library to target.
module.exports = {
plugins: [
[
'@clair/inject-style',
{
packageName: 'yourUILibrary'
}
]
]
}
Default: '@clair/theme-default'
If the style files are released under another package, this would become handy.
Support you want to import Button
with pure JavaScript and load its style automatically, then you can
module.exports = {
plugins: [
'@clair/inject-style',
{
packageName: 'yourUILibrary',
stylePackageName: 'yourDesignatedStyleLibrary'
}
]
}
There is a path matching pattern underneath
const stylePath = `${stylePackageName}/styles/${computedComponentName}${extension}`
This may not be what you want. Then try getStylePath.
You can only pass function in
babel.config.js
.
To maximize the flexibility to compute your own style path, you can
module.exports = {
plugins: [
'@clair/inject-style',
{
packageName: 'yourUILibrary',
getStylePath(componentName) {
return computeStylePath(componentName)
}
}
]
}
getStylePath
accept one parameter componentName
.
It is name of the imported
named import or the default import.
For example, in case like import { a as b } from 'libaray'
, a
is the componentName
here.
By using this,
stylePackageName
andextension
will be ignored.
Default: '.scss'
.
The extension of style files. You can change it to anything you want.
It will be ignored if you are using
getStylePath
.
FAQs
When import a given component, import its corresponding style file automatically.
We found that @clair/babel-plugin-inject-style demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.