Skip to content

Commit

Permalink
chore(release): v3.0.0-beta.11
Browse files Browse the repository at this point in the history
  • Loading branch information
oasis-cloud committed Jan 3, 2025
1 parent 93d8a67 commit f4285a4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nutui/nutui-react-taro",
"version": "3.0.0-beta.10",
"name": "@nutui/nutui-react",
"version": "3.0.0-beta.11",
"style": "dist/style.css",
"main": "dist/nutui.react.umd.js",
"module": "dist/es/packages/nutui.react.build.js",
Expand Down
6 changes: 6 additions & 0 deletions scripts/build-taro.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ async function buildCSS(p) {
`import './style.css'`,
)

// copy harmonycss
if (file.indexOf('countup') === -1) {
await copy(join(__dirname, '../', file.replace('scss', 'harmony.css')), join('dist/cjs', cssPath, 'style/style.harmony.css'))
await copy(join(__dirname, '../', file.replace('scss', 'harmony.css')), join('dist/es', cssPath, 'style/style.harmony.css'))
}

// 删除 import
// 写入 style.scss
const atRules = []
Expand Down
64 changes: 64 additions & 0 deletions scripts/replace-css-var.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* 通过 dist 目录下的 style/index.js 构建每个组件的 css 文件
* */
const path = require('path')
const fs = require('fs')
const postcss = require('postcss')
const sass = require('sass')
const cssvariables = require('postcss-css-variables')
const config = require('../src/config.json')

const components = config.nav.reduce(
(prev, nav) => [...prev, ...nav.packages],
[],
)

const mixin = fs
.readFileSync(path.join(__dirname, '../src/styles/mixins/text-ellipsis.scss'))
.toString()
const variables = fs.readFileSync(
path.join(__dirname, '../src/styles/variables.scss'),
).toString()

const theme = fs.readFileSync(
path.join(__dirname, '../src/styles/theme-default.scss'),
).toString()

const exclude = ['icon']
components.forEach((component) => {
const componentName = component.name.toLowerCase()
if (exclude.includes(componentName)) return

let content = fs
.readFileSync(
path.join(
__dirname,
`../src/packages/${componentName}/${componentName}.scss`,
),
)
.toString()
let to = path.join(
__dirname,
`../src/packages/${componentName}/${componentName}.harmony.css`,
)
const matched = content.match(/@import.*?[;][\n\r]?/gi)
if (matched) {
matched.forEach((m) => {
if (m.indexOf('styles') > -1) {
content = content.replace(m, mixin)
} else {
content = content.replace(m, '')
}
})
}

const res = sass.compileString(theme + variables + content)
postcss([
cssvariables(/*options*/),
])
.process(res.css, { to })
.then((result) => {
fs.writeFile(to, result.css, () => {
})
})
})

0 comments on commit f4285a4

Please sign in to comment.