forked from jdf2e/nutui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-rtl.js
37 lines (34 loc) · 1.05 KB
/
generate-rtl.js
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
32
33
34
35
36
37
const postcss = require('postcss')
const rtl = require('postcss-rtlcss')
const fs = require('fs')
const path = require('path')
const scss = require('postcss-scss')
const config = require('../src/config.json')
const components = config.nav.reduce(
(prev, nav) => [...prev, ...nav.packages],
[]
)
console.log(components.length)
const plugins = [
rtl({ mode: 'override', rtlPrefix: [`[dir="rtl"]`, `.nut-rtl`] }),
]
components.forEach((component) => {
const componentName = component.name.toLowerCase()
if (componentName === 'icon') return
// if (componentName === 'icon' || componentName === 'col') return
// if(componentName !== 'col') return
const readFrom = path.join(
process.cwd(),
`./src/packages/${componentName}/${componentName}.scss`
)
const writeTo = path.join(
process.cwd(),
`./src/packages/${componentName}/${componentName}.scss`
)
const css = fs.readFileSync(readFrom, 'utf8')
postcss(plugins)
.process(css, { syntax: scss })
.then((result) => {
fs.writeFile(writeTo, result.css, () => {})
})
})