Skip to content

Commit

Permalink
feat: #1 前端css框架采用stylus-兼容博客与思源笔记主题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 1, 2023
1 parent 7cefde8 commit c506a21
Show file tree
Hide file tree
Showing 22 changed files with 474 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ dist-cjs
.sass-cache
*.css
*.css.map
package
build
script/__pycache__
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ pnpm build

3. <kbd>设置</kbd> - <kbd>外观</kbd> - <kbd>主题</kbd> 选择 `zhi` 主题即可

## npm发包
```bash
# 验证打包
npm pack

# 本地验证
npm publish --dry-run

# 发布到仓库
npm publish
```

## 项目结构

Vite + React + TypeScript + SWC
Expand Down
20 changes: 15 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"version": "0.0.0",
"scripts": {
"dev": "vite",
"watch:css": "stylus -r -w theme.styl -o theme.css",
"watch:css": "stylus -w theme.styl -o theme.css",
"watch:js": "tsc && vite build -c vite.cjs.config.ts --outDir dist-cjs --watch",
"build": "pnpm build:cjs && pnpm build:esm",
"build:cjs": "tsc && vite build -c vite.cjs.config.ts --outDir dist-cjs",
"build:esm": "tsc && vite build",
"build": "python script/build.py",
"build:css": "python script/css.py",
"build:cjs": "python script/cjs.py",
"build:esm": "python script/esm.py",
"preview": "vite preview",
"test": "vitest",
"coverage": "vitest run --coverage"
Expand All @@ -26,6 +27,15 @@
"stylus": "^0.59.0",
"typescript": "^4.9.3",
"vite": "^4.1.0",
"vite-plugin-stylus-alias": "^1.1.2",
"vitest": "^0.28.5"
}
},
"files": [
"dist",
"dist-cjs",
"theme.css",
"theme.js",
"theme.json",
"README.md"
]
}
14 changes: 14 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions script/build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright (c) 2023, Terwer . All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Terwer designates this
# particular file as subject to the "Classpath" exception as provided
# by Terwer in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
# or visit www.terwer.space if you need additional information or have any
# questions.
import os

import scriptutils

if __name__ == "__main__":
# 切换工作空间
scriptutils.switch_workdir()

scriptutils.rm_folder("./dist")
scriptutils.rm_folder("./dist-cjs")
os.system("pnpm build:css")
os.system("pnpm build:cjs")
os.system("pnpm build:esm")
print("zhi构建完成.")
38 changes: 38 additions & 0 deletions script/cjs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright (c) 2023, Terwer . All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Terwer designates this
# particular file as subject to the "Classpath" exception as provided
# by Terwer in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
# or visit www.terwer.space if you need additional information or have any
# questions.

import os

import scriptutils

if __name__ == "__main__":
# 切换工作空间
scriptutils.switch_workdir()

scriptutils.rm_folder("./dist-cjs")
os.system("tsc && vite build -c vite.cjs.config.ts --outDir dist-cjs")
scriptutils.rm_folder("./dist-cjs/fonts")
scriptutils.rm_folder("./dist-cjs/lib")
scriptutils.rm_file("./dist-cjs/vite.svg")
print("cjs构建完成.")

34 changes: 34 additions & 0 deletions script/css.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Copyright (c) 2023, Terwer . All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Terwer designates this
# particular file as subject to the "Classpath" exception as provided
# by Terwer in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
# or visit www.terwer.space if you need additional information or have any
# questions.

import os

import scriptutils

if __name__ == "__main__":
# 切换工作空间
scriptutils.switch_workdir()

os.system("stylus -c theme.styl -o theme.css")
print("css构建完成.")

33 changes: 33 additions & 0 deletions script/esm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) 2023, Terwer . All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Terwer designates this
# particular file as subject to the "Classpath" exception as provided
# by Terwer in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
# or visit www.terwer.space if you need additional information or have any
# questions.
import os

import scriptutils

if __name__ == "__main__":
# 切换工作空间
scriptutils.switch_workdir()

scriptutils.rm_folder("./dist")
os.system("tsc && vite build")
print("esm构建完成.")
Loading

0 comments on commit c506a21

Please sign in to comment.