-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathesbuildPlugins.mjs
More file actions
31 lines (28 loc) · 972 Bytes
/
esbuildPlugins.mjs
File metadata and controls
31 lines (28 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import lightningCssPlugin from 'unplugin-lightningcss/esbuild';
// Due to a bug in unplugin, we cannot use the Lightning CSS unplugin directly.
// https://github.com/unjs/unplugin/issues/546
// To workaround the bug, we are converting it back to esbuild plugin so we can apply a custom `filter`.
// Otherwise, unplugin will apply `filter: /.*/` and trigger the bug down the road.
/** @type { import('esbuild').Plugin } */
const cssPlugin = {
name: 'lightningcss',
setup: build => {
lightningCssPlugin({
include: [/\.module\.css$/u],
options: {
cssModules: {
pattern: 'w[hash]_[local]',
pure: true,
animation: false,
grid: false,
customIdents: false
}
}
}).setup({
...build,
// eslint-disable-next-line require-unicode-regexp
onLoad: (_filter, fn) => build.onLoad({ filter: /(\.module_built\.css|\?css_module)$/ }, fn)
});
}
};
export { cssPlugin };