Skip to content

Commit

Permalink
chore: add @weapp-tailwindcss/postcss pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
sonofmagic committed Jan 10, 2025
1 parent 05fb1e5 commit b1664a7
Show file tree
Hide file tree
Showing 36 changed files with 2,779 additions and 213 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"@commitlint/prompt-cli": "^19.7.0",
"@commitlint/types": "^19.5.0",
"@eslint/config-inspector": "^0.7.1",
"@icebreakers/eslint-config": "^0.7.10",
"@icebreakers/eslint-config": "^0.7.11",
"@icebreakers/monorepo": "^0.6.22",
"@icebreakers/readme": "0.1.0",
"@icebreakers/stylelint-config": "^0.1.3",
Expand Down Expand Up @@ -191,7 +191,7 @@
"js-beautify": "^1.15.1",
"jsdom": "^26.0.0",
"klaw": "^4.1.0",
"lightningcss": "^1.29.0",
"lightningcss": "^1.29.1",
"lint-staged": "^15.3.0",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
Expand Down Expand Up @@ -229,7 +229,7 @@
"turbo": "^2.3.3",
"typescript": "^5.7.3",
"unbuild": "^3.2.0",
"uuid": "^11.0.4",
"uuid": "^11.0.5",
"vinyl": "^3.0.0",
"vinyl-fs": "^4.0.0",
"vite": "^6.0.7",
Expand Down
56 changes: 56 additions & 0 deletions packages/postcss/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@weapp-tailwindcss/postcss",
"version": "0.0.0",
"description": "@weapp-tailwindcss/postcss",
"author": "ice breaker <[email protected]>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/sonofmagic/monorepo-template.git",
"directory": "packages/bar"
},
"bugs": {
"url": "https://github.com/sonofmagic/monorepo-template/issues"
},
"keywords": [],
"sideEffects": false,
"exports": {
".": "./src/index.ts"
},
"files": [
"dist"
],
"scripts": {
"dev": "tsup --watch --sourcemap",
"build": "tsup",
"test": "vitest run",
"test:dev": "vitest",
"release": "pnpm publish",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
},
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
},
"./types": {
"types": "./dist/types.d.ts",
"import": "./dist/types.mjs",
"require": "./dist/types.js"
}
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts"
},
"dependencies": {
"@weapp-core/escape": "~3.0.2",
"@weapp-tailwindcss/shared": "workspace:*",
"postcss": "~8.4.49",
"postcss-rem-to-responsive-pixel": "~6.0.2",
"postcss-selector-parser": "~7.0.0"
}
}
1 change: 1 addition & 0 deletions packages/postcss/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const postcssPlugin = 'postcss-weapp-tailwindcss-rename-plugin'
206 changes: 206 additions & 0 deletions packages/postcss/src/cssVars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
export default [
{
prop: '--tw-border-spacing-x',
value: '0',
},
{
prop: '--tw-border-spacing-y',
value: '0',
},
{
prop: '--tw-translate-x',
value: '0',
},
{
prop: '--tw-translate-y',
value: '0',
},
{
prop: '--tw-rotate',
value: '0',
},
{
prop: '--tw-skew-x',
value: '0',
},
{
prop: '--tw-skew-y',
value: '0',
},
{
prop: '--tw-scale-x',
value: '1',
},
{
prop: '--tw-scale-y',
value: '1',
},
{
prop: '--tw-pan-x',
value: ' ',
},
{
prop: '--tw-pan-y',
value: ' ',
},
{
prop: '--tw-pinch-zoom',
value: ' ',
},
{
prop: '--tw-scroll-snap-strictness',
value: 'proximity',
},
{
prop: '--tw-gradient-from-position',
value: ' ',
},
{
prop: '--tw-gradient-via-position',
value: ' ',
},
{
prop: '--tw-gradient-to-position',
value: ' ',
},
{
prop: '--tw-ordinal',
value: ' ',
},
{
prop: '--tw-slashed-zero',
value: ' ',
},
{
prop: '--tw-numeric-figure',
value: ' ',
},
{
prop: '--tw-numeric-spacing',
value: ' ',
},
{
prop: '--tw-numeric-fraction',
value: ' ',
},
{
prop: '--tw-ring-inset',
value: ' ',
},
{
prop: '--tw-ring-offset-width',
value: '0px',
},
{
prop: '--tw-ring-offset-color',
value: '#fff',
},
{
prop: '--tw-ring-color',
value: 'rgb(59 130 246 / 0.5)',
},
{
prop: '--tw-ring-offset-shadow',
value: '0 0 #0000',
},
{
prop: '--tw-ring-shadow',
value: '0 0 #0000',
},
{
prop: '--tw-shadow',
value: '0 0 #0000',
},
{
prop: '--tw-shadow-colored',
value: '0 0 #0000',
},
{
prop: '--tw-blur',
value: ' ',
},
{
prop: '--tw-brightness',
value: ' ',
},
{
prop: '--tw-contrast',
value: ' ',
},
{
prop: '--tw-grayscale',
value: ' ',
},
{
prop: '--tw-hue-rotate',
value: ' ',
},
{
prop: '--tw-invert',
value: ' ',
},
{
prop: '--tw-saturate',
value: ' ',
},
{
prop: '--tw-sepia',
value: ' ',
},
{
prop: '--tw-drop-shadow',
value: ' ',
},
{
prop: '--tw-backdrop-blur',
value: ' ',
},
{
prop: '--tw-backdrop-brightness',
value: ' ',
},
{
prop: '--tw-backdrop-contrast',
value: ' ',
},
{
prop: '--tw-backdrop-grayscale',
value: ' ',
},
{
prop: '--tw-backdrop-hue-rotate',
value: ' ',
},
{
prop: '--tw-backdrop-invert',
value: ' ',
},
{
prop: '--tw-backdrop-opacity',
value: ' ',
},
{
prop: '--tw-backdrop-saturate',
value: ' ',
},
{
prop: '--tw-backdrop-sepia',
value: ' ',
},
{
prop: '--tw-contain-size',
value: ' ',
},
{
prop: '--tw-contain-layout',
value: ' ',
},
{
prop: '--tw-contain-paint',
value: ' ',
},
{
prop: '--tw-contain-style',
value: ' ',
},
]
24 changes: 24 additions & 0 deletions packages/postcss/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { IStyleHandlerOptions } from './types'
import { defuOverrideArray } from '@weapp-tailwindcss/shared'
import postcss from 'postcss'
import { getPlugins } from './plugins'

export function styleHandler(rawSource: string, options: IStyleHandlerOptions) {
return postcss(getPlugins(options))
.process(
rawSource,
options.postcssOptions?.options ?? {
from: undefined,
},
)
.async()
}

export function createStyleHandler(options: Partial<IStyleHandlerOptions>) {
return (rawSource: string, opt?: Partial<IStyleHandlerOptions>) => {
return styleHandler(
rawSource,
defuOverrideArray<IStyleHandlerOptions, Partial<IStyleHandlerOptions>[]>(opt as IStyleHandlerOptions, options),
)
}
}
Loading

0 comments on commit b1664a7

Please sign in to comment.