Skip to content

Commit

Permalink
chore: 打包流程 css 分包
Browse files Browse the repository at this point in the history
  • Loading branch information
EricWXY committed May 26, 2024
1 parent f329496 commit 8e962ce
Show file tree
Hide file tree
Showing 30 changed files with 9,051 additions and 606 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"@eric-ui/hooks": "workspace:*",
"@eric-ui/theme": "workspace:*",
"@eric-ui/utils": "workspace:*",
"eric-ui": "workspace:*",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@fortawesome/free-solid-svg-icons": "^6.5.1",
"@fortawesome/vue-fontawesome": "^3.0.6",
"@popperjs/core": "^2.11.8",
"async-validator": "^4.2.5",
"eric-ui": "workspace:*",
"lodash-es": "^4.17.21",
"vue": "^3.4.19"
},
Expand All @@ -34,13 +34,13 @@
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/tsconfig": "^0.5.1",
"move-file-cli": "^3.0.0",
"npm-run-all": "^4.1.5",
"postcss-color-mix": "^1.1.0",
"postcss-each": "^1.1.0",
"postcss-each-variables": "^0.3.0",
"postcss-for": "^2.1.1",
"postcss-nested": "^6.0.1",
"shelljs": "^0.8.5",
"typescript": "^5.2.2",
"vite": "^5.1.4",
"vitest": "^1.4.0",
Expand Down
8 changes: 5 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"dist"
],
"sideEffects": [
"./dist/index.css"
"./dist/index.css",
"./dist/theme"
],
"main": "./dist/umd/index.umd.cjs",
"module": "./dist/es/index.js",
Expand All @@ -24,16 +25,17 @@
}
},
"scripts": {
"build": "run-s build-only move-style",
"build": "run-s build-only move-themes",
"build-only": "run-p build-es build-umd",
"build-es": "vite build --config vite.es.config.ts",
"build-umd": "vite build --config vite.umd.config.ts",
"move-style": "move-file dist/es/index.css dist/index.css"
"move-themes":"node ./scripts/moveThemes.js"
},
"keywords": [],
"author": "EricWXY",
"license": "ISC",
"devDependencies": {
"vite-plugin-compression": "^0.5.1",
"vite-plugin-dts": "^3.9.1"
},
"dependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/core/scripts/moveThemes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import shell from 'shelljs'

shell.mv('./dist/umd/index.css','./dist/index.css')
shell.mv('./dist/es/theme', './dist' )
11 changes: 11 additions & 0 deletions packages/core/vite.es.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import dts from "vite-plugin-dts";
import compression from "vite-plugin-compression";

const COMP_NAMES = [
"Alert",
Expand Down Expand Up @@ -30,9 +31,13 @@ export default defineConfig({
tsconfigPath: "../../tsconfig.build.json",
outDir: "dist/types",
}),
compression({
threshold: 1024 * 50,
}),
],
build: {
outDir: "dist/es",
cssCodeSplit: true,
lib: {
entry: resolve(__dirname, "./index.ts"),
name: "EricUI",
Expand All @@ -53,6 +58,12 @@ export default defineConfig({
if (chunkInfo.name === "style.css") {
return "index.css";
}
if (
chunkInfo.type === "asset" &&
/\.(css)$/i.test(chunkInfo.name as string)
) {
return "theme/[name].[ext]";
}
return chunkInfo.name as string;
},
manualChunks(id) {
Expand Down
2 changes: 2 additions & 0 deletions packages/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vitepress/dist
.vitepress/cache

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

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

Large diffs are not rendered by default.

Loading

0 comments on commit 8e962ce

Please sign in to comment.