@lls/vitescripts 2.0.10 → 2.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -3
- package/src/esbuildCssModulePlugin.mjs +31 -0
- package/src/index.mjs +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lls/vitescripts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.11",
|
|
4
4
|
"description": "lls vite plugins",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"files": [
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "CONF_ENV=test npx vitest run",
|
|
11
|
-
"
|
|
11
|
+
"postinstall": "test \"$INIT_CWD\" = \"$PWD\" && npx husky install || echo 'Skipping postinstall"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"lightningcss": "1.22.
|
|
14
|
+
"lightningcss": "1.22.1"
|
|
15
15
|
},
|
|
16
16
|
"type": "module",
|
|
17
17
|
"author": "",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
"@lls/eslint-config-lls": "1.1.12",
|
|
21
21
|
"@lls/lls-kit": "20.1.0",
|
|
22
22
|
"browserslist": "4.22.1",
|
|
23
|
+
"esbuild-plugin-lightningcss-modules": "0.1.1",
|
|
23
24
|
"husky": "8.0.3",
|
|
24
25
|
"vitest": "0.34.6"
|
|
25
26
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import llsCssModuleMacroPlugin from './llsCssModuleMacroPlugin.mjs'
|
|
3
|
+
import { cssModules } from 'esbuild-plugin-lightningcss-modules'
|
|
4
|
+
|
|
5
|
+
export default ({ prefix = '', llsCssModuleMacroPluginArg }) => {
|
|
6
|
+
const esbuildCssModule = cssModules({
|
|
7
|
+
targets: { chrome: 80 << 16 },
|
|
8
|
+
drafts: { nesting: true },
|
|
9
|
+
cssModulesPattern: `${prefix ? prefix + '-' : ''}[hash]-[local]`
|
|
10
|
+
})
|
|
11
|
+
return [
|
|
12
|
+
{
|
|
13
|
+
name: 'lls-cssmodule',
|
|
14
|
+
async setup(build) {
|
|
15
|
+
const llsCssModuleMacroPluginInstance = await llsCssModuleMacroPlugin(llsCssModuleMacroPluginArg)
|
|
16
|
+
build.onLoad({ filter: /module\.css$/ }, async args => {
|
|
17
|
+
if (args.path.startsWith('/tmp')) return
|
|
18
|
+
const contents = await fs.promises.readFile(args.path, 'utf8').then(str => llsCssModuleMacroPluginInstance.transform(str, args.path))
|
|
19
|
+
const id = args.path.replace(process.cwd(), '').replace(/\//g, '_')
|
|
20
|
+
const outName = `/tmp/${id}`
|
|
21
|
+
await fs.promises.writeFile(outName, contents)
|
|
22
|
+
return {
|
|
23
|
+
contents: `export { default } from '${outName}'`,
|
|
24
|
+
loader: 'js'
|
|
25
|
+
}
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
esbuildCssModule
|
|
30
|
+
]
|
|
31
|
+
}
|
package/src/index.mjs
CHANGED
|
@@ -6,4 +6,5 @@ export { default as llsSideRefreshMetaPlugin } from './llsSideRefreshMetaPlugin.
|
|
|
6
6
|
export { default as llsVitestMockPlugin } from './llsVitestMockPlugin.mjs'
|
|
7
7
|
export { default as llsLadlePlugin } from './llsLadlePlugin.mjs'
|
|
8
8
|
export { default as llsCssModuleMacroPlugin } from './llsCssModuleMacroPlugin.mjs'
|
|
9
|
-
export { default as postBuildAutoprefixerPlugin } from './postBuildAutoprefixerPlugin.mjs'
|
|
9
|
+
export { default as postBuildAutoprefixerPlugin } from './postBuildAutoprefixerPlugin.mjs'
|
|
10
|
+
export { default as esbuildCssModulePlugin } from './esbuildCssModulePlugin.mjs'
|