@lls/vitescripts 2.0.2 → 2.0.4
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
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lls/vitescripts",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "lls vite plugins",
|
|
5
5
|
"main": "src/index.mjs",
|
|
6
6
|
"files": [
|
|
7
7
|
"src/"
|
|
8
8
|
],
|
|
9
9
|
"scripts": {
|
|
10
|
-
"test": "
|
|
10
|
+
"test": "CONF_ENV=test npx vitest run",
|
|
11
|
+
"prepare": "husky install || true"
|
|
11
12
|
},
|
|
12
13
|
"dependencies": {
|
|
13
|
-
"lightningcss": "1.
|
|
14
|
+
"lightningcss": "1.22.0"
|
|
14
15
|
},
|
|
15
16
|
"type": "module",
|
|
16
17
|
"author": "",
|
|
17
18
|
"license": "ISC",
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@lls/eslint-config-lls": "1.1.12"
|
|
20
|
+
"@lls/eslint-config-lls": "1.1.12",
|
|
21
|
+
"@lls/lls-kit": "20.1.0",
|
|
22
|
+
"browserslist": "4.22.1",
|
|
23
|
+
"husky": "8.0.3",
|
|
24
|
+
"vitest": "0.34.6"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@lls/lls-kit": "*"
|
|
20
28
|
}
|
|
21
29
|
}
|
package/src/index.mjs
CHANGED
|
@@ -6,3 +6,4 @@ 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'
|
|
@@ -1,4 +1,21 @@
|
|
|
1
1
|
const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, themeIsNotDarkMode }) => {
|
|
2
|
+
const keepProperties = [
|
|
3
|
+
'Supporting',
|
|
4
|
+
'Button1',
|
|
5
|
+
'Button2',
|
|
6
|
+
'Body1',
|
|
7
|
+
'Body2',
|
|
8
|
+
'Body3',
|
|
9
|
+
'RippleEffect',
|
|
10
|
+
'Heading1',
|
|
11
|
+
'Heading2',
|
|
12
|
+
'Heading3',
|
|
13
|
+
'Heading4'
|
|
14
|
+
]
|
|
15
|
+
const kitBag = await import('@lls/lls-kit')
|
|
16
|
+
.then(m => m.default || m)
|
|
17
|
+
.then(obj => Object.fromEntries(keepProperties.map(property => [property, obj[property]])))
|
|
18
|
+
|
|
2
19
|
const cssMacroTheme = {
|
|
3
20
|
themeIsFreeMode,
|
|
4
21
|
themeIsDarkMode,
|
|
@@ -11,6 +28,20 @@ const llsCssModuleMacroPlugin = async ({ themeIsFreeMode, themeIsDarkMode, theme
|
|
|
11
28
|
return undefined
|
|
12
29
|
}
|
|
13
30
|
return src
|
|
31
|
+
.replace(/\${(Body[123]|Heading[123])}/g, (__, cap) => kitBag[cap])
|
|
32
|
+
.replace(/\${getFluidSize\({(.*?)}\)}/gs, (__, cap) => {
|
|
33
|
+
const args = {
|
|
34
|
+
minViewport: 320, // BREAKPOINT_XXS
|
|
35
|
+
maxViewport: 1280, // BREAKPOINT_MD
|
|
36
|
+
minSize: undefined,
|
|
37
|
+
maxSize: undefined
|
|
38
|
+
}
|
|
39
|
+
for (const a of cap.matchAll(/(?<prop>maxSize|minSize|minViewport|maxViewport)\s*:\s*(?<value>.+?)(?=[, ]|$)/g)) {
|
|
40
|
+
args[a.groups.prop] = a.groups.value
|
|
41
|
+
}
|
|
42
|
+
const { maxSize, minSize, minViewport, maxViewport} = args
|
|
43
|
+
return `min(${maxSize}px, max(${minSize}px, calc(${minSize}px + (${maxSize} - ${minSize}) * ((100vw - ${minViewport}px) / (${maxViewport} - ${minViewport})))))`
|
|
44
|
+
})
|
|
14
45
|
.replace(/\${getTruePx\((.*?)\)}/g, 'calc(var(--size-index, 1) * $1 * 1px)')
|
|
15
46
|
.replace(/\${(themeIsFreeMode|themeIsDarkMode|themeIsNotDarkMode)}/g, (__, cap) => {
|
|
16
47
|
const back = cssMacroTheme[cap]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
|
|
3
|
+
const esbuildAutoprefixerPlugin = async ({ from, to }) => {
|
|
4
|
+
const [{ transform, browserslistToTargets }, browserslist] = await Promise.all([import('lightningcss'), import('browserslist').then(m => m.default)])
|
|
5
|
+
const contents = await fs.promises.readFile(from).then(async buf => {
|
|
6
|
+
const {code} = transform({
|
|
7
|
+
code: buf,
|
|
8
|
+
targets: browserslistToTargets(browserslist('cover 99.5%'))
|
|
9
|
+
})
|
|
10
|
+
return code.toString()
|
|
11
|
+
})
|
|
12
|
+
return fs.promises.writeFile(to, contents)
|
|
13
|
+
}
|
|
14
|
+
export default esbuildAutoprefixerPlugin
|