
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
unplugin-mantine-autoload-css
Advanced tools
Unplugin for Mantine to autoload CSS for used components
Mantine Unplugin to autoload CSS for used components
vite.config.ts
import { defineConfig } from 'vite'
import { mantineAutoloadCSS } from 'unplugin-mantine-autoload-css'
export default defineConfig({
plugins: [
mantineAutoloadCSS(),
]
})
all: Boolean / Default: falseInstead of component detecting, load
@mantine/core/styles.cssfor each file with import from@mantine/core
Hint: If you want to use this plugin only for build optimization, you can use it conditionally:
export default defineConfig(({ mode }) => ({
plugins: [
mantineAutoloadCSS({
all: mode === 'development',
}),
],
}))
layer: Boolean / Default: trueSwitch between
.cssand.layer.cssfiles
forced: ComponentStylesheetName[] / Default: []Add some components' CSS for each file with import from
@mantine/core
baseline: Boolean / Default: trueLoad
baseline.css/baseline.layer.css— a minimal CSS reset, sets box-sizing: border-box and changes font properties
defaultCSSVariables: Boolean / Default: trueLoad
default-css-variables.css/default-css-variables.layer.css— contains all CSS variables generated from the default theme
global: Boolean / Default: trueLoad
global.css/global.layer.css— global classes used in Mantine components
allDependencies: Boolean / Default: trueSome components like Select do not have any styles on their own – they are built on top of other components. So we cannot automate that without lurking Mantine sources. If you are not sure which components are used in a particular component, you can import all styles for components that are reused in other components. https://mantine.dev/styles/css-files-list/#components-dependencies
In Mantine, you have to manually import CSS for components you use.
Reason: there is two versions of CSS for each component: .css and .layer.css, so you have to decide what to use. Official answer is “Mantine is not a building tool”, so I decided to fill this gap.
You can just import all Mantine CSS containing every CSS for every Mantine component:
import '@mantine/core/styles.css'
but you will import CSS for components you don't use in your project.
styles.css is 226KB
Vite plugin looking for imports from @mantine/core for each your source .ts or .tsx file, adding CSS imports based on hypothesis that every component has CSS named after it.
Example: if you add this to MyComponent.tsx:
import { Accordion } from '@mantine/core'
So we want to add this to MyComponent.tsx:
import '@mantine/core/styles/Accordion.css'
In @mantine/core/styles directory, we have all CSS files we want:
Accordion.css
Accordion.layer.css
ActionIcon.css
ActionIcon.layer.css
… and so on
So I automated this.
(Don't worry about import duplication: any bundler will deduplicate them across bundle)
FAQs
Unplugin for Mantine to autoload CSS for used components
We found that unplugin-mantine-autoload-css demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.