-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(theme): when release theme, copy dist to _dist and replace cssvar… (
#1768) * fix(theme): when release theme, copy dist to _dist and replace cssvar's prefix name * fix(vue-theme): update package's version
- Loading branch information
1 parent
f2d1a8d
commit 6f186c2
Showing
2 changed files
with
49 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,40 @@ | ||
/** | ||
* 将 dist 目录生成 TGZ 的压缩包 | ||
* 将 dist 目录生成 TGZ 的压缩包 fs.cp 需要node 18.0+ | ||
*/ | ||
|
||
const fs = require('node:fs') | ||
const path = require('node:path') | ||
const { execSync } = require('node:child_process') | ||
const fg = require('fast-glob') | ||
|
||
const source = 'dist' | ||
const content = fs.readFileSync(path.join(source, 'index.css')).toString('UTF-8') | ||
// 提供特殊的前缀名称 | ||
const result = content.replace(/--ti-/g, '--ti-vue-') | ||
const packagesPath = path.join(source, 'lowcode.css') | ||
// 替换文件内容。 如果不指定target,则原地覆盖 | ||
function replaceFile(src, cb, target = null) { | ||
let content = fs.readFileSync(src, 'utf8') | ||
content = cb(content) | ||
fs.writeFileSync(target || src, content, 'utf8') | ||
} | ||
|
||
fs.writeFileSync(packagesPath, result) | ||
// 1、从 index.css 生成 lowcode.css ------ 提供特殊的前缀名称 | ||
replaceFile('dist/index.css', (content) => content.replace(/--ti-/g, '--ti-vue-'), 'dist/lowcode.css') | ||
|
||
fs.copyFileSync('package.json', path.join(source, 'package.json')) | ||
// 2、复制一份冗余的文件,统一替换 --ti- 前缀为 --tvue- ,避免混用 tiny3时,css变量名冲突。 | ||
fs.cpSync('dist', '_dist', { recursive: true, force: true }) | ||
fs.cpSync('_dist', 'dist/_dist', { recursive: true, force: true }) | ||
fs.rmSync('_dist', { recursive: true, force: true }) | ||
// 2.1 处理所有的 index.css | ||
let files = fg.sync(['dist/_dist/**/index.css']) | ||
files.forEach((file) => { | ||
replaceFile(file, (content) => content.replace(/--ti-/g, '--tvue-')) | ||
}) | ||
// 2.2 处理所有的说主题js | ||
files = fg.sync(['dist/_dist/**/{aurora,smb}-theme.js', 'dist/_dist/theme/**/{index,component}.js']) | ||
files.forEach((file) => { | ||
replaceFile(file, (content) => | ||
content | ||
.replace(/--ti-/g, '--tvue-') // | ||
.replace(/'ti-/g, `'tvue-`) | ||
) | ||
}) | ||
|
||
// 3、复制package.json/README.md到dist目录 | ||
fs.copyFileSync('package.json', path.join('dist', 'package.json')) | ||
fs.copyFileSync('README.md', path.join('dist', 'README.md')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
{ | ||
"name": "@opentiny/vue-theme", | ||
"version": "3.17.3", | ||
"version": "3.17.4", | ||
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.", | ||
"main": "index.css", | ||
"author": "OpenTiny Team", | ||
"license": "MIT", | ||
"homepage": "https://opentiny.design/tiny-vue", | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:opentiny/tiny-vue.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/opentiny/tiny-vue/issues" | ||
}, | ||
"keywords": [ | ||
"vue", | ||
"vue3", | ||
|
@@ -15,24 +23,16 @@ | |
"renderless-components", | ||
"headless-components" | ||
], | ||
"author": "OpenTiny Team", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "[email protected]:opentiny/tiny-vue.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/opentiny/tiny-vue/issues" | ||
}, | ||
"exports": { | ||
"./*": "./src/*" | ||
}, | ||
"main": "index.css", | ||
"scripts": { | ||
"clean": "rimraf dist src/aurora-theme src/smb-theme", | ||
"build:theme": "gulp build --gulpfile build/gulp-dist.js", | ||
"build": "npm run clean && npm run build:theme && node build/replace-img.js", | ||
"build:fast": "npm run build && npm run release", | ||
"release": "node build/release.js && node build/postbuild.js && shx cp README.md dist", | ||
"release": "node build/release.js && node build/postbuild.js", | ||
"build:copy-remote": "npm run build:theme && cp-cli dist ../tiny-vue/node_modules/@opentiny/vue-theme", | ||
"publishTgz": "node .cloudbuild/publish-tgzs.js", | ||
"postversion": "pnpm build", | ||
|
@@ -42,18 +42,18 @@ | |
"@babel/cli": "^7.5.5", | ||
"@babel/core": "^7.5.5", | ||
"@babel/preset-env": "^7.5.5", | ||
"fast-glob": "^3.2.12", | ||
"gulp": "^4.0.2", | ||
"gulp-autoprefixer": "^7.0.1", | ||
"gulp-clean-css": "^4.2.0", | ||
"gulp-concat": "2.6.1", | ||
"gulp-less": "^5.0.0", | ||
"gulp-svg-inline": "^1.0.1", | ||
"gulp-transform": "3.0.5", | ||
"gulp-concat": "2.6.1", | ||
"svgo": "3.2.0", | ||
"rimraf": "^2.6.2", | ||
"fast-glob": "^3.2.12", | ||
"stylelint": "^14.14.0", | ||
"stylelint-config-standard": "^29.0.0" | ||
"stylelint-config-standard": "^29.0.0", | ||
"svgo": "3.2.0" | ||
}, | ||
"stylelint": { | ||
"extends": [ | ||
|
@@ -87,4 +87,4 @@ | |
] | ||
} | ||
} | ||
} | ||
} |