Skip to content

version:0.0.3 #21

Merged
merged 17 commits into from
Feb 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/azure-staticwebapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
run: pnpm install

- name: Use pnpm to build
run: pnpm run build
run: pnpm run build:release

# - name: post-build test
# run: pnpm test
Expand Down
103 changes: 103 additions & 0 deletions .github/workflows/dev-cloudflare-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
name: Deploy DEV EOEFANS WEB to Cloudflare pages

on:
push:
branches: [ "main","ci" ]
# pull_request:
# types: [synchronize, closed]
# branches: [ "main","ci" ]

# Environment variables available to all jobs and steps in this workflow
env:
APP_LOCATION: "/" # location of your client code
APP_ARTIFACT_LOCATION: "dist" # location of client code build output
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
PROJECT_NAME: eoefans-web-dev

permissions:
contents: read

jobs:
build_and_deploy_job:
permissions:
contents: read
deployments: write
pull-requests: write # for Azure/static-web-apps-deploy to comment on PRs
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
runs-on: [ self-hosted, Linux ]
environment:
name: 'Development'

strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

name: Build and Deploy Job
steps:
- uses: actions/checkout@v3
with:
submodules: true


- uses: actions/setup-node@v3
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Use pnpm to build
run: pnpm run build

# - name: post-build test
# run: pnpm test

- name: Publish
uses: cloudflare/pages-action@1
with:
apiToken: ${{ env.CLOUDFLARE_API_TOKEN }}
accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.PROJECT_NAME }} # e.g. 'my-project'
directory: ${{ env.APP_ARTIFACT_LOCATION }} # e.g. 'dist'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}

close_pull_request_job:
permissions:
contents: none
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: [ self-hosted, Linux ]
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: cloudflare/pages-action@1
with:
apiToken: ${{ env.CLOUDFLARE_API_TOKEN }}
accountId: ${{ env.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ env.RPOJECT_NAME }} # e.g. 'my-project'
directory: ${{ env.APP_ARTIFACT_LOCATION }} # e.g. 'dist'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.0.3](/compare/v0.0.2...v0.0.3) (2023-02-19)


### ✅ Tests

* **custom**: 本地测试完成,测试release环境 cf38ad8


### 🐛 Bug Fixes

* **custom**: 删除js文件内的map映射 7d2f1f5



## [0.0.2](/compare/v0.0.1...v0.0.2) (2023-02-19)


### 🎫 Chores

* **custom**: 添加changelog e06f400



## 0.0.1 (2023-02-19)


### ✨ Features

* **custom**: 添加entry ca939da, closes #15


### 🎫 Chores

* **custom**: 添加commit规范 77cc224, closes #12


### 🐛 Bug Fixes

* **custom**: 修复构建错误 1359691
* **custom**: 修复token问题 58b1a8d
7 changes: 7 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ fileList.forEach((file) => {
const full_name_file = path.join(filePath, file);
if (path.extname(full_name_file) === ".map") {
fs.unlinkSync(full_name_file);
} else if (path.extname(full_name_file) === ".js") {
const data = fs.readFileSync(full_name_file, "utf-8");
const result = data.replace(
RegExp(`//# sourceMappingURL=[0-9A-Za-z-]*.js.map`, "g"),
""
);
fs.writeFileSync(full_name_file, result, "utf-8");
}
});

Expand Down
File renamed without changes.
42 changes: 42 additions & 0 deletions config/vite.dev.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig } from "vite";
import path from "path";
import react from "@vitejs/plugin-react-swc";
//redictPath
export const addProjectPath = (originPath: string) => `../${originPath}`;
import { createHtmlPlugin } from "vite-plugin-html";
export default defineConfig({
define: {
__APP_VERSION__: "0.01",
isdev: true,
isrelease: false,
},
resolve: {
alias: {
"@utils": path.resolve(__dirname, addProjectPath("src/utils")),
"@components": path.resolve(__dirname, addProjectPath("src/components")),
"@store": path.resolve(__dirname, addProjectPath("src/store")),
"@routers": path.resolve(__dirname, addProjectPath("src/routers")),
"@assets": path.resolve(__dirname, addProjectPath("src/assets")),
},
},
plugins: [
react(),
createHtmlPlugin({
entry: "src/main.tsx",
template: "index.html",
inject: {
data: {
injectScript: ``,
},
},
}),
],
server: {
proxy: {
"/v1": {
target: "https://api.eoe.best/eoefans-api",
changeOrigin: true,
},
},
},
});
63 changes: 18 additions & 45 deletions vite.config.ts → config/vite.master.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import { defineConfig, loadEnv } from "vite";
import path from "path";
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
// 可视化打包文件
import { visualizer } from "rollup-plugin-visualizer";
// packagejson
import packageJson from "./package.json";

// gzip
import viteCompression from "vite-plugin-compression";
// polyfill
import legacy from "@vitejs/plugin-legacy";
//sentry
import viteSentry from "vite-plugin-sentry";

//get build time
import getBulidTime from "./getbuildtime";

//redictPath
export const addProjectPath = (originPath: string) => `../${originPath}`;

const ProdinjectScript = `<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-DTCJR7156E"></script>
<script>
Expand All @@ -33,25 +32,17 @@ gtag('config', 'G-DTCJR7156E');
</script>
`;
import { createHtmlPlugin } from "vite-plugin-html";
import { mergeConfig } from "vite";
import vitedevConfig from "./vite.dev.config";
// https://vitejs.dev/config/
//@ts-ignore
export default defineConfig(({ mode }) => {
return {
export default mergeConfig(
vitedevConfig,
defineConfig({
define: {
__APP_VERSION__: "0.01",
isdev: mode === "development",
},
resolve: {
alias: {
"@utils": path.resolve(__dirname, "src/utils"),
"@components": path.resolve(__dirname, "src/components"),
"@store": path.resolve(__dirname, "src/store"),
"@routers": path.resolve(__dirname, "src/routers"),
"@assets": path.resolve(__dirname, "src/assets"),
},
isdev: false,
},
plugins: [
react(),
legacy({
// 设置目标浏览器,browserslist 配置语法
targets: [
Expand All @@ -66,27 +57,17 @@ export default defineConfig(({ mode }) => {
template: "index.html",
inject: {
data: {
injectScript: mode === "development" ? `` : ProdinjectScript,
injectScript: ProdinjectScript,
},
},
}),
//@ts-ignore
getBulidTime(),
{
...viteSentry({
configFile: ".sentryclirc",
sourceMaps: {
include: ["./dist/assets"],
},
release: "eoefans-web@" + packageJson.version,
// headers: {
// "Expect-CT": `max-age=86400, enforce,report-uri="https://sentry.vtb.link/api/3/security/?sentry_key=086f27258cce4d28aacc8c2719a683fb"`,
// },
}),
apply: "build",
},
],
build: {
sourcemap: true,
outDir: "dist",
emptyOutDir: true,
reportCompressedSize: false,
minify: "esbuild",
rollupOptions: {
Expand Down Expand Up @@ -120,13 +101,5 @@ export default defineConfig(({ mode }) => {
},
},
},
server: {
proxy: {
"/v1": {
target: "https://api.eoe.best/eoefans-api",
changeOrigin: true,
},
},
},
};
});
})
);
29 changes: 29 additions & 0 deletions config/vite.release.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// packagejson
import packageJson from "../package.json";
//sentry
import viteSentry from "vite-plugin-sentry";

import { defineConfig, mergeConfig } from "vite";
import viteMasterConfig, { addProjectPath } from "./vite.master.config";
const config = mergeConfig(
viteMasterConfig,
defineConfig({
define: {
isrelease: true,
},
plugins: [
{
...viteSentry({
configFile: ".sentryclirc",
sourceMaps: {
include: [addProjectPath("./dist/assets")],
},
release: "eoefans-web@" + packageJson.version,
}),
apply: "build",
},
],
})
);

export default config;
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "eoefans-web",
"version": "0.0.1",
"version": "0.0.3",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build && node build.js",
"dev": "vite --config ./config/vite.dev.config.ts",
"build": "tsc && vite build --config ./config/vite.master.config.ts && node build.js",
"preview": "vite preview",
"commit": "cz"
"commit": "cz",
"build:release": "vite build --config ./config/vite.release.config.ts && node build.js",
"release:changelog": "standard-version --preset gitmoji-config"
},
"config": {
"commitizen": {
Expand Down Expand Up @@ -60,11 +62,13 @@
"commitizen": "^4.3.0",
"commitlint": "^17.4.3",
"commitlint-config-gitmoji": "^2.3.1",
"conventional-changelog-gitmoji-config": "^1.4.7",
"cz-conventional-changelog": "^3.3.0",
"cz-customizable": "^7.0.0",
"husky": "^8.0.3",
"less": "^4.1.3",
"rollup-plugin-visualizer": "^5.9.0",
"standard-version": "^9.5.0",
"terser": "^5.16.3",
"typescript": "^4.9.5",
"vite": "4.1.1",
Expand Down
Loading