Skip to content

Commit f3cc537

Browse files
authored
feat(theme-doc): remove antd global style from theme-doc (#94)
* build theme-doc without antd global style fix: #93 * chore: publish * fix global style. extract less-plugin-remove-antd-global-styles * chore: publish beta * revert unnecessary changes * chore: publish beta * fix tsconfig * fix package.json for merge
1 parent 921297e commit f3cc537

File tree

7 files changed

+36
-3
lines changed

7 files changed

+36
-3
lines changed

packages/playground/use-theme-doc/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@types/react": "^17.0.3",
2424
"@types/react-router-dom": "^5.1.7",
2525
"@vitejs/plugin-react": "^2.1.0",
26+
"less-plugin-remove-antd-global-styles": "^1.0.1",
2627
"rimraf": "^3.0.2",
2728
"serve": "^14.0.1",
2829
"vite": "^3.1.0",

packages/playground/use-theme-doc/vite.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from 'path'
33
import react from '@vitejs/plugin-react'
44
import _mdx from 'vite-plugin-mdx'
55
import pages from 'vite-plugin-react-pages'
6+
import { LessPluginRemoveAntdGlobalStyles } from 'less-plugin-remove-antd-global-styles'
67

78
// vite-plugin-mdx is not esm friendly currently
89
const mdx = ((_mdx as any).default || _mdx) as typeof _mdx
@@ -28,6 +29,7 @@ export default defineConfig({
2829
'ant-prefix': 'vp-antd',
2930
},
3031
javascriptEnabled: true,
32+
plugins: [new LessPluginRemoveAntdGlobalStyles()],
3133
},
3234
},
3335
modules: {

packages/theme-doc/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vite-pages-theme-doc",
3-
"version": "3.3.1",
3+
"version": "3.4.0",
44
"description": "A document theme for vite-plugin-react-pages.",
55
"main": "dist-cjs/index.js",
66
"module": "dist/index.js",
@@ -52,6 +52,7 @@
5252
"github-slugger": "^1.3.0",
5353
"globby": "^11.0.2",
5454
"less": "^4.1.3",
55+
"less-plugin-remove-antd-global-styles": "^1.0.2",
5556
"postcss": "^8.4.16",
5657
"prism-react-renderer": "^1.3.5",
5758
"rc-footer": "^0.6.6",

packages/theme-doc/rollup.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import postcss from 'rollup-plugin-postcss'
22
import babel from '@rollup/plugin-babel'
33
import commonjs from '@rollup/plugin-commonjs'
44
import resolve from '@rollup/plugin-node-resolve'
5+
import { LessPluginRemoveAntdGlobalStyles } from 'less-plugin-remove-antd-global-styles'
56

67
const extensions = ['.js', '.jsx', '.ts', '.tsx']
78

@@ -69,6 +70,7 @@ export default {
6970
'ant-prefix': 'vp-antd',
7071
},
7172
javascriptEnabled: true,
73+
plugins: [new LessPluginRemoveAntdGlobalStyles()],
7274
},
7375
},
7476
modules: {

packages/theme-doc/src/style.less

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1-
body {
2-
background: #fff;
1+
// take useful css normalize from antd, so that antd components rendered by this theme can display normally
2+
// https://github.com/ant-design/ant-design/blob/master/components/style/core/global.less
3+
// but don't take global style that may interfere with user's content
4+
5+
// this is a reasonable global style
6+
*,
7+
*::before,
8+
*::after {
9+
box-sizing: border-box;
10+
}
11+
12+
// only apply to elements rendered by this theme
13+
// avoid interfering with user's content
14+
.vp-local-header a,
15+
.vp-local-sider a {
16+
text-decoration: none;
317
}

packages/theme-doc/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
2+
"exclude": ["./lib/**/*"],
23
"extends": "../../tsconfig.json",
34
"compilerOptions": {
45
"module": "CommonJS",

pnpm-lock.yaml

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)