create-packer 1.45.12 → 1.45.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/package.json +1 -1
  2. package/template/web-app/react-rsbuild/.gitignore +5 -0
  3. package/template/web-app/react-rsbuild/domain/app/components/app-context.tsx +10 -1
  4. package/template/web-app/react-rsbuild/env.d.ts +14 -7
  5. package/template/web-app/react-rsbuild/main.tsx +0 -1
  6. package/template/web-app/react-rsbuild/package.json +4 -3
  7. package/template/web-app/react-rsbuild/pages/home/view.styled.ts +5 -0
  8. package/template/web-app/react-rsbuild/pages/home/view.tsx +2 -2
  9. package/template/web-app/react-rsbuild/rsbuild.config.ts +10 -2
  10. package/template/web-app/react-rsbuild/shared/styles/global.ts +7 -0
  11. package/template/web-app/react-rsbuild/shared/styles/index.ts +2 -1
  12. package/template/web-app/react-rsbuild/shared/styles/theme.ts +60 -0
  13. package/template/web-app/react-rsbuild/tsconfig.json +1 -0
  14. package/template/web-app/react-vite/.gitignore +4 -0
  15. package/template/web-app/react-vite/domain/app/components/app-context.tsx +10 -1
  16. package/template/web-app/react-vite/eslint.config.js +1 -1
  17. package/template/web-app/react-vite/main.tsx +0 -1
  18. package/template/web-app/react-vite/package.json +78 -78
  19. package/template/web-app/react-vite/pages/home/view.styled.ts +5 -0
  20. package/template/web-app/react-vite/pages/home/view.tsx +2 -2
  21. package/template/web-app/react-vite/postcss.config.cjs +8 -8
  22. package/template/web-app/react-vite/shared/styles/global.ts +7 -0
  23. package/template/web-app/react-vite/shared/styles/index.ts +2 -1
  24. package/template/web-app/react-vite/shared/styles/theme.ts +60 -0
  25. package/template/web-app/react-vite/tsconfig.json +1 -0
  26. package/template/web-app/react-vite/vite-env.d.ts +14 -6
  27. package/template/web-app/react-vite/vite.config.ts +5 -3
  28. package/template/web-app/svelte/package.json +1 -1
  29. package/template/web-app/vue/package.json +1 -1
  30. package/template/web-app/vue-rsbuild/package.json +1 -1
  31. package/template/web-extension/entrypoints/content/domain/app/tools/insertApp.tsx +3 -1
  32. package/template/web-extension/entrypoints/content/modules/common/common.tsx +0 -2
  33. package/template/web-extension/entrypoints/popup/main.tsx +0 -1
  34. package/template/web-extension/package.json +4 -3
  35. package/template/web-extension/shared/components/app-context/view.tsx +11 -2
  36. package/template/web-extension/shared/styles/global.ts +9 -0
  37. package/template/web-extension/shared/styles/index.ts +2 -2
  38. package/template/web-extension/shared/styles/theme.ts +60 -0
  39. package/template/web-extension/tsconfig.json +1 -0
  40. package/template/web-extension/vite-env.d.ts +6 -0
  41. package/template/web-extension/wxt.config.ts +8 -2
  42. package/template/web-app/react-rsbuild/global.css.ts +0 -5
  43. package/template/web-app/react-rsbuild/pages/home/view.css.ts +0 -7
  44. package/template/web-app/react-rsbuild/shared/styles/theme.css.ts +0 -3
  45. package/template/web-app/react-vite/.husky/pre-commit +0 -4
  46. package/template/web-app/react-vite/global.css.ts +0 -5
  47. package/template/web-app/react-vite/pages/home/view.css.ts +0 -7
  48. package/template/web-app/react-vite/shared/styles/theme.css.ts +0 -3
  49. package/template/web-extension/entrypoints/content/global.css.ts +0 -5
  50. package/template/web-extension/entrypoints/popup/global.css.ts +0 -4
  51. package/template/web-extension/shared/styles/global.css.ts +0 -7
  52. package/template/web-extension/shared/styles/theme.css.ts +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.45.12",
3
+ "version": "1.45.14",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -26,3 +26,8 @@ vite.config.ts.*
26
26
  *.njsproj
27
27
  *.sln
28
28
  *.sw?
29
+
30
+
31
+ ## Panda
32
+ styled-system
33
+ styled-system-studio
@@ -1,6 +1,8 @@
1
1
  import { FunctionComponent, ReactNode } from 'react'
2
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
+ import { Global, ThemeProvider } from '@emotion/react'
3
4
  import { request } from '@/shared/service'
5
+ import { globalCss, theme } from '@/shared/styles'
4
6
 
5
7
  const queryClient = new QueryClient({
6
8
  defaultOptions: {
@@ -18,5 +20,12 @@ export interface propsType {
18
20
  children: ReactNode
19
21
  }
20
22
  export const Root: FunctionComponent<propsType> = props => {
21
- return <QueryClientProvider client={queryClient}>{props.children}</QueryClientProvider>
23
+ return (
24
+ <ThemeProvider theme={theme}>
25
+ <QueryClientProvider client={queryClient}>
26
+ <Global styles={globalCss} />
27
+ {props.children}
28
+ </QueryClientProvider>
29
+ </ThemeProvider>
30
+ )
22
31
  }
@@ -1,14 +1,17 @@
1
1
  /// <reference types="@rsbuild/core/types" />
2
+ import '@emotion/react'
3
+ import { type themeType } from '@/shared/styles'
2
4
 
3
- interface ImportMetaEnv {
4
- readonly PUBLIC_BASE_URL: string
5
- readonly PUBLIC_API_HOST: string
6
- }
5
+ declare global {
6
+ interface ImportMetaEnv {
7
+ readonly PUBLIC_BASE_URL: string
8
+ readonly PUBLIC_API_HOST: string
9
+ }
7
10
 
8
- interface ImportMeta {
9
- readonly env: ImportMetaEnv
11
+ interface ImportMeta {
12
+ readonly env: ImportMetaEnv
13
+ }
10
14
  }
11
-
12
15
  declare module '*.svg' {
13
16
  const content: string
14
17
  export default content
@@ -18,3 +21,7 @@ declare module '*.svg?react' {
18
21
  const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement>>
19
22
  export default ReactComponent
20
23
  }
24
+
25
+ declare module '@emotion/react' {
26
+ export interface Theme extends themeType {}
27
+ }
@@ -1,4 +1,3 @@
1
1
  import { startApp } from '@/domain/app'
2
- import './global.css'
3
2
 
4
3
  startApp()
@@ -4,7 +4,7 @@
4
4
  "version": "0.0.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
- "prepare": "husky install",
7
+ "prepare": "husky",
8
8
  "dev": "rsbuild dev",
9
9
  "build": "rsbuild build",
10
10
  "build:analyse": "rsbuild build --env-mode analyse",
@@ -19,8 +19,9 @@
19
19
  "commit": "git add . && npm run cz"
20
20
  },
21
21
  "dependencies": {
22
+ "@emotion/react": "11.14.0",
23
+ "@emotion/styled": "11.14.1",
22
24
  "@tanstack/react-query": "5.51.15",
23
- "@vanilla-extract/css": "1.17.4",
24
25
  "axios": "1.7.9",
25
26
  "define-zustand": "3.4.0",
26
27
  "es-toolkit": "1.39.8",
@@ -44,11 +45,11 @@
44
45
  "@rsbuild/plugin-svgr": "1.2.2",
45
46
  "@rsbuild/plugin-type-check": "1.2.4",
46
47
  "@rsdoctor/rspack-plugin": "1.2.3",
48
+ "@swc/plugin-emotion": "11.1.0",
47
49
  "@types/node": "18.16.0",
48
50
  "@types/qs": "6.9.7",
49
51
  "@types/react": "18.3.3",
50
52
  "@types/react-dom": "18.3.0",
51
- "@vanilla-extract/webpack-plugin": "2.3.22",
52
53
  "autoprefixer": "10.4.14",
53
54
  "commitizen": "4.3.0",
54
55
  "cross-env": "7.0.3",
@@ -0,0 +1,5 @@
1
+ import styled from '@emotion/styled'
2
+
3
+ export const StyledRoot = styled.div`
4
+ ${({ theme }) => theme.tools.flex('center', 'center')}
5
+ `
@@ -1,10 +1,10 @@
1
1
  import { useHomeData } from '@/shared/service'
2
- import * as styles from './view.css'
2
+ import { StyledRoot } from './view.styled'
3
3
 
4
4
  export default function Home() {
5
5
  const { data } = useHomeData()
6
6
 
7
7
  console.log('data', data)
8
8
 
9
- return <div className={styles.root}>sdfs</div>
9
+ return <StyledRoot>sdfs</StyledRoot>
10
10
  }
@@ -4,7 +4,6 @@ import { pluginEslint } from '@rsbuild/plugin-eslint'
4
4
  import StylelintWebpackPlugin from 'stylelint-webpack-plugin'
5
5
  import { pluginTypeCheck } from '@rsbuild/plugin-type-check'
6
6
  import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
7
- import { VanillaExtractPlugin } from '@vanilla-extract/webpack-plugin'
8
7
  import { pluginSvgr } from '@rsbuild/plugin-svgr'
9
8
  import { createChunks } from './scripts'
10
9
 
@@ -39,10 +38,16 @@ export default defineConfig(({ envMode, command }) => {
39
38
  tools: {
40
39
  rspack: {
41
40
  plugins: [
42
- new VanillaExtractPlugin(),
43
41
  new StylelintWebpackPlugin(),
44
42
  process.env.RSDOCTOR && new RsdoctorRspackPlugin()
45
43
  ]
44
+ },
45
+ swc: {
46
+ jsc: {
47
+ experimental: {
48
+ plugins: [['@swc/plugin-emotion', {}]]
49
+ }
50
+ }
46
51
  }
47
52
  },
48
53
  plugins: [
@@ -57,6 +62,9 @@ export default defineConfig(({ envMode, command }) => {
57
62
  pluginReact({
58
63
  reactRefreshOptions: {
59
64
  exclude: [/\.css\.ts$/]
65
+ },
66
+ swcReactOptions: {
67
+ importSource: '@emotion/react'
60
68
  }
61
69
  })
62
70
  ],
@@ -0,0 +1,7 @@
1
+ import { css } from '@emotion/react'
2
+
3
+ export const globalCss = css`
4
+ body {
5
+ margin: 0;
6
+ }
7
+ `
@@ -1 +1,2 @@
1
- export * from './theme.css'
1
+ export * from './global'
2
+ export * from './theme'
@@ -0,0 +1,60 @@
1
+ import { CSSProperties } from 'react'
2
+ import { isString } from 'es-toolkit'
3
+ import { isNumber } from 'es-toolkit/compat'
4
+
5
+ export const theme = {
6
+ text: {
7
+ xs: { fontSize: '12px', lineHeight: '20px' },
8
+ sm: { fontSize: '14px', lineHeight: '22px' },
9
+ base: { fontSize: '16px', lineHeight: '24px' },
10
+ lg: { fontSize: '18px', lineHeight: '26px' },
11
+ xl: { fontSize: '20px', lineHeight: '28px' },
12
+ '2xl': { fontSize: '24px', lineHeight: '32px' },
13
+ '3xl': { fontSize: '28px', lineHeight: '40px' },
14
+ '4xl': { fontSize: '32px', lineHeight: '44px' }
15
+ } satisfies Record<string, CSSProperties>,
16
+ tools: {
17
+ ellipsis: () => ({
18
+ overflow: 'hidden',
19
+ textOverflow: 'ellipsis',
20
+ whiteSpace: 'nowrap'
21
+ }),
22
+ lineClamp: (n: number) => ({
23
+ '-webkit-line-clamp': `${n}`,
24
+ '-webkit-box-orient': 'vertical',
25
+ overflow: 'hidden',
26
+ display: '-webkit-box'
27
+ }),
28
+ size: (s: string) => ({ width: s, height: s }),
29
+ py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
30
+ px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
31
+ my: (s: string) => ({ marginTop: s, marginBottom: s }),
32
+ mx: (s: string) => ({ marginLeft: s, marginRight: s }),
33
+ flex: (
34
+ align: CSSProperties['alignItems'],
35
+ justify: CSSProperties['justifyContent'],
36
+ vertical?: boolean
37
+ ) => {
38
+ return {
39
+ display: 'flex',
40
+ alignItems: align,
41
+ justifyContent: justify,
42
+ flexDirection: vertical ? 'column' : 'row'
43
+ } satisfies CSSProperties
44
+ },
45
+ /** 数字为元素数量,字符串为对应css的值 */
46
+ grid: (
47
+ rows: number | CSSProperties['gridTemplateRows'],
48
+ cols: number | CSSProperties['gridTemplateColumns'],
49
+ gap?: number | string
50
+ ) => {
51
+ return {
52
+ display: 'grid',
53
+ gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
54
+ gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
55
+ gap: isNumber(gap) ? `${gap}px` : gap
56
+ } satisfies CSSProperties
57
+ }
58
+ }
59
+ }
60
+ export type themeType = typeof theme
@@ -18,6 +18,7 @@
18
18
  "isolatedModules": true,
19
19
  "noEmit": true,
20
20
  "jsx": "react-jsx",
21
+ "jsxImportSource": "@emotion/react",
21
22
  "paths": {
22
23
  "@/*": ["./*"]
23
24
  }
@@ -26,3 +26,7 @@ vite.config.ts.*
26
26
  *.njsproj
27
27
  *.sln
28
28
  *.sw?
29
+
30
+ ## Panda
31
+ styled-system
32
+ styled-system-studio
@@ -1,6 +1,8 @@
1
1
  import { FunctionComponent, ReactNode } from 'react'
2
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
+ import { Global, ThemeProvider } from '@emotion/react'
3
4
  import { request } from '@/shared/service'
5
+ import { globalCss, theme } from '@/shared/styles'
4
6
 
5
7
  const queryClient = new QueryClient({
6
8
  defaultOptions: {
@@ -18,5 +20,12 @@ export interface propsType {
18
20
  children: ReactNode
19
21
  }
20
22
  export const Root: FunctionComponent<propsType> = props => {
21
- return <QueryClientProvider client={queryClient}>{props.children}</QueryClientProvider>
23
+ return (
24
+ <ThemeProvider theme={theme}>
25
+ <QueryClientProvider client={queryClient}>
26
+ <Global styles={globalCss} />
27
+ {props.children}
28
+ </QueryClientProvider>
29
+ </ThemeProvider>
30
+ )
22
31
  }
@@ -16,7 +16,7 @@ export default tseslint.config([
16
16
  '**/.history/',
17
17
  '**/.vscode/',
18
18
  'vite.config.ts.*',
19
- 'mockUtils.ts'
19
+ 'mockUtils.ts',
20
20
  ]
21
21
  },
22
22
  eslint.configs.recommended,
@@ -1,4 +1,3 @@
1
1
  import { startApp } from '@/domain/app'
2
- import './global.css'
3
2
 
4
3
  startApp()
@@ -1,78 +1,78 @@
1
- {
2
- "name": "react-vite",
3
- "private": true,
4
- "version": "0.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "prepare": "husky install",
8
- "dev": "vite",
9
- "build": "tsc --noEmit && vite build",
10
- "build:analyse": "tsc --noEmit && vite build --mode analyse",
11
- "preview": "vite preview",
12
- "up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L",
13
- "format": "prettier --write \"**/*.{ts,js,tsx,jsx,json,css,scss,less}\"",
14
- "lint": "tsc --noEmit && eslint --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less,ts,tsx}",
15
- "lint:fix": "eslint --fix && stylelint **/*.{css,scss,less,ts,tsx} --fix",
16
- "cz": "cz",
17
- "push": "npm run commit && git push",
18
- "commit": "git add . && npm run cz"
19
- },
20
- "dependencies": {
21
- "@tanstack/react-query": "5.51.15",
22
- "@vanilla-extract/css": "1.17.4",
23
- "axios": "1.7.9",
24
- "define-zustand": "3.4.0",
25
- "es-toolkit": "1.39.8",
26
- "immer": "10.0.1",
27
- "qs": "6.11.2",
28
- "react": "18.3.1",
29
- "react-dom": "18.3.1",
30
- "react-router": "7.5.0",
31
- "react-use": "17.5.0",
32
- "type-fest": "4.33.0",
33
- "zustand": "5.0.3"
34
- },
35
- "devDependencies": {
36
- "@commitlint/cli": "17.6.1",
37
- "@commitlint/config-conventional": "17.6.1",
38
- "@commitlint/cz-commitlint": "17.5.0",
39
- "@emotion/babel-plugin": "11.13.5",
40
- "@eslint/js": "9.15.0",
41
- "@faker-js/faker": "8.4.1",
42
- "@types/node": "18.16.0",
43
- "@types/qs": "6.9.7",
44
- "@types/react": "18.3.3",
45
- "@types/react-dom": "18.3.0",
46
- "@vanilla-extract/vite-plugin": "5.1.1",
47
- "@vitejs/plugin-react": "5.0.1",
48
- "autoprefixer": "10.4.14",
49
- "commitizen": "4.3.0",
50
- "cssnano": "6.0.0",
51
- "eslint": "9.17.0",
52
- "eslint-import-resolver-typescript": "3.7.0",
53
- "eslint-plugin-import": "2.31.0",
54
- "eslint-plugin-react": "7.37.2",
55
- "eslint-plugin-react-hooks": "5.1.0",
56
- "globals": "15.12.0",
57
- "husky": "9.1.6",
58
- "inquirer": "^8.1.2",
59
- "postcss": "8.4.35",
60
- "postcss-import": "16.0.1",
61
- "postcss-nesting": "12.0.3",
62
- "prettier": "3.2.5",
63
- "rollup-plugin-visualizer": "5.12.0",
64
- "stylelint": "16.10.0",
65
- "stylelint-config-standard": "36.0.1",
66
- "typescript": "5.8.2",
67
- "typescript-eslint": "8.15.0",
68
- "vite": "7.1.3",
69
- "vite-plugin-checker": "0.10.2",
70
- "vite-plugin-mock-dev-server": "1.9.3",
71
- "vite-plugin-svgr": "4.5.0"
72
- },
73
- "config": {
74
- "commitizen": {
75
- "path": "@commitlint/cz-commitlint"
76
- }
77
- }
78
- }
1
+ {
2
+ "name": "react-vite",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "prepare": "husky",
8
+ "dev": "vite",
9
+ "build": "tsc --noEmit && vite build",
10
+ "build:analyse": "tsc --noEmit && vite build --mode analyse",
11
+ "preview": "vite preview",
12
+ "up:vite": "pnpm up vite @vitejs/* vite-plugin-* -L",
13
+ "format": "prettier --write \"**/*.{ts,js,tsx,jsx,json,css,scss,less}\"",
14
+ "lint": "tsc --noEmit && eslint --no-error-on-unmatched-pattern && stylelint **/*.{css,scss,less,ts,tsx}",
15
+ "lint:fix": "eslint --fix && stylelint **/*.{css,scss,less,ts,tsx} --fix",
16
+ "cz": "cz",
17
+ "push": "npm run commit && git push",
18
+ "commit": "git add . && npm run cz"
19
+ },
20
+ "dependencies": {
21
+ "@emotion/react": "11.14.0",
22
+ "@emotion/styled": "11.14.1",
23
+ "@tanstack/react-query": "5.51.15",
24
+ "axios": "1.7.9",
25
+ "define-zustand": "3.4.0",
26
+ "es-toolkit": "1.39.8",
27
+ "immer": "10.0.1",
28
+ "qs": "6.11.2",
29
+ "react": "18.3.1",
30
+ "react-dom": "18.3.1",
31
+ "react-router": "7.5.0",
32
+ "react-use": "17.5.0",
33
+ "type-fest": "4.33.0",
34
+ "zustand": "5.0.3"
35
+ },
36
+ "devDependencies": {
37
+ "@commitlint/cli": "17.6.1",
38
+ "@commitlint/config-conventional": "17.6.1",
39
+ "@commitlint/cz-commitlint": "17.5.0",
40
+ "@emotion/babel-plugin": "11.13.5",
41
+ "@eslint/js": "9.15.0",
42
+ "@faker-js/faker": "8.4.1",
43
+ "@types/node": "18.16.0",
44
+ "@types/qs": "6.9.7",
45
+ "@types/react": "18.3.3",
46
+ "@types/react-dom": "18.3.0",
47
+ "@vitejs/plugin-react": "5.0.1",
48
+ "autoprefixer": "10.4.14",
49
+ "commitizen": "4.3.0",
50
+ "cssnano": "6.0.0",
51
+ "eslint": "9.17.0",
52
+ "eslint-import-resolver-typescript": "3.7.0",
53
+ "eslint-plugin-import": "2.31.0",
54
+ "eslint-plugin-react": "7.37.2",
55
+ "eslint-plugin-react-hooks": "5.1.0",
56
+ "globals": "15.12.0",
57
+ "husky": "9.1.6",
58
+ "inquirer": "8.1.2",
59
+ "postcss": "8.4.35",
60
+ "postcss-import": "16.0.1",
61
+ "postcss-nesting": "12.0.3",
62
+ "prettier": "3.2.5",
63
+ "rollup-plugin-visualizer": "5.12.0",
64
+ "stylelint": "16.10.0",
65
+ "stylelint-config-standard": "36.0.1",
66
+ "typescript": "5.8.2",
67
+ "typescript-eslint": "8.15.0",
68
+ "vite": "7.1.3",
69
+ "vite-plugin-checker": "0.10.2",
70
+ "vite-plugin-mock-dev-server": "1.9.3",
71
+ "vite-plugin-svgr": "4.5.0"
72
+ },
73
+ "config": {
74
+ "commitizen": {
75
+ "path": "@commitlint/cz-commitlint"
76
+ }
77
+ }
78
+ }
@@ -0,0 +1,5 @@
1
+ import styled from '@emotion/styled'
2
+
3
+ export const StyledRoot = styled.div`
4
+ ${({ theme }) => theme.tools.flex('center', 'center')}
5
+ `
@@ -1,10 +1,10 @@
1
1
  import { useHomeData } from '@/shared/service'
2
- import * as styles from './view.css'
2
+ import { StyledRoot } from './view.styled'
3
3
 
4
4
  export default function Home() {
5
5
  const { data } = useHomeData()
6
6
 
7
7
  console.log('data', data)
8
8
 
9
- return <div className={styles.root}>sdfs</div>
9
+ return <StyledRoot>sdfs</StyledRoot>
10
10
  }
@@ -1,8 +1,8 @@
1
- module.exports = {
2
- plugins: {
3
- 'postcss-import': {},
4
- 'postcss-nesting': {},
5
- autoprefixer: {},
6
- ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
7
- }
8
- }
1
+ module.exports = {
2
+ plugins: {
3
+ 'postcss-import': {},
4
+ 'postcss-nesting': {},
5
+ autoprefixer: {},
6
+ ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {})
7
+ }
8
+ }
@@ -0,0 +1,7 @@
1
+ import { css } from '@emotion/react'
2
+
3
+ export const globalCss = css`
4
+ body {
5
+ margin: 0;
6
+ }
7
+ `
@@ -1 +1,2 @@
1
- export * from './theme.css'
1
+ export * from './global'
2
+ export * from './theme'
@@ -0,0 +1,60 @@
1
+ import { CSSProperties } from 'react'
2
+ import { isString } from 'es-toolkit'
3
+ import { isNumber } from 'es-toolkit/compat'
4
+
5
+ export const theme = {
6
+ text: {
7
+ xs: { fontSize: '12px', lineHeight: '20px' },
8
+ sm: { fontSize: '14px', lineHeight: '22px' },
9
+ base: { fontSize: '16px', lineHeight: '24px' },
10
+ lg: { fontSize: '18px', lineHeight: '26px' },
11
+ xl: { fontSize: '20px', lineHeight: '28px' },
12
+ '2xl': { fontSize: '24px', lineHeight: '32px' },
13
+ '3xl': { fontSize: '28px', lineHeight: '40px' },
14
+ '4xl': { fontSize: '32px', lineHeight: '44px' }
15
+ } satisfies Record<string, CSSProperties>,
16
+ tools: {
17
+ ellipsis: () => ({
18
+ overflow: 'hidden',
19
+ textOverflow: 'ellipsis',
20
+ whiteSpace: 'nowrap'
21
+ }),
22
+ lineClamp: (n: number) => ({
23
+ '-webkit-line-clamp': `${n}`,
24
+ '-webkit-box-orient': 'vertical',
25
+ overflow: 'hidden',
26
+ display: '-webkit-box'
27
+ }),
28
+ size: (s: string) => ({ width: s, height: s }),
29
+ py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
30
+ px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
31
+ my: (s: string) => ({ marginTop: s, marginBottom: s }),
32
+ mx: (s: string) => ({ marginLeft: s, marginRight: s }),
33
+ flex: (
34
+ align: CSSProperties['alignItems'],
35
+ justify: CSSProperties['justifyContent'],
36
+ vertical?: boolean
37
+ ) => {
38
+ return {
39
+ display: 'flex',
40
+ alignItems: align,
41
+ justifyContent: justify,
42
+ flexDirection: vertical ? 'column' : 'row'
43
+ } satisfies CSSProperties
44
+ },
45
+ /** 数字为元素数量,字符串为对应css的值 */
46
+ grid: (
47
+ rows: number | CSSProperties['gridTemplateRows'],
48
+ cols: number | CSSProperties['gridTemplateColumns'],
49
+ gap?: number | string
50
+ ) => {
51
+ return {
52
+ display: 'grid',
53
+ gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
54
+ gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
55
+ gap: isNumber(gap) ? `${gap}px` : gap
56
+ } satisfies CSSProperties
57
+ }
58
+ }
59
+ }
60
+ export type themeType = typeof theme
@@ -18,6 +18,7 @@
18
18
  "isolatedModules": true,
19
19
  "noEmit": true,
20
20
  "jsx": "react-jsx",
21
+ "jsxImportSource": "@emotion/react",
21
22
  "paths": {
22
23
  "@/*": ["./*"]
23
24
  }
@@ -1,12 +1,20 @@
1
1
  /// <reference types="vite/client" />
2
2
  /// <reference types="vite-plugin-svgr/client" />
3
+ import '@emotion/react'
4
+ import { type themeType } from '@/shared/styles'
3
5
 
4
- interface ImportMetaEnv {
5
- readonly VITE_BASE_URL: string
6
- readonly VITE_API_HOST: string
7
- // 更多环境变量...
6
+ declare global {
7
+ interface ImportMetaEnv {
8
+ readonly VITE_BASE_URL: string
9
+ readonly VITE_API_HOST: string
10
+ // 更多环境变量...
11
+ }
12
+
13
+ interface ImportMeta {
14
+ readonly env: ImportMetaEnv
15
+ }
8
16
  }
9
17
 
10
- interface ImportMeta {
11
- readonly env: ImportMetaEnv
18
+ declare module '@emotion/react' {
19
+ export interface Theme extends themeType {}
12
20
  }
@@ -4,7 +4,6 @@ import svgr from 'vite-plugin-svgr'
4
4
  import { mockDevServerPlugin } from 'vite-plugin-mock-dev-server'
5
5
  import checker from 'vite-plugin-checker'
6
6
  import { visualizer } from 'rollup-plugin-visualizer'
7
- import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'
8
7
  import { createChunks } from './scripts'
9
8
 
10
9
  // https://vitejs.dev/config/
@@ -12,7 +11,6 @@ export default defineConfig(({ mode }) => {
12
11
  const env = loadEnv(mode, process.cwd(), '')
13
12
  const proxyBaseUrl = env.VITE_BASE_URL + env.VITE_API_HOST
14
13
  const plugins: any[] = [
15
- vanillaExtractPlugin(),
16
14
  svgr(),
17
15
  mockDevServerPlugin({
18
16
  include: ['**/*.mock.{ts,js}']
@@ -22,7 +20,11 @@ export default defineConfig(({ mode }) => {
22
20
  typescript: true,
23
21
  eslint: { useFlatConfig: true, lintCommand: 'eslint', dev: { logLevel: ['error'] } }
24
22
  }),
25
- react()
23
+ react({
24
+ babel: {
25
+ plugins: ['@emotion']
26
+ }
27
+ })
26
28
  ]
27
29
 
28
30
  if (mode === 'analyse') {
@@ -4,7 +4,7 @@
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
7
- "prepare": "husky install",
7
+ "prepare": "husky",
8
8
  "dev": "cross-env MODE=development vite",
9
9
  "build": "npm run check && npm run lint && cross-env MODE=production vite build",
10
10
  "build:analyse": "npm run check && npm run lint && vite build --mode analyse",
@@ -4,7 +4,7 @@
4
4
  "version": "0.0.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
- "prepare": "husky install",
7
+ "prepare": "husky",
8
8
  "dev": "vite",
9
9
  "build": "vue-tsc --noEmit && vite build",
10
10
  "build:analyse": "tsc --noEmit && vite build --mode analyse",
@@ -4,7 +4,7 @@
4
4
  "version": "0.0.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
- "prepare": "husky install",
7
+ "prepare": "husky",
8
8
  "dev": "rsbuild dev",
9
9
  "build": "rsbuild build",
10
10
  "build:analyse": "rsbuild build --env-mode analyse",
@@ -50,7 +50,9 @@ export function insertApp<T extends HTMLElement>(
50
50
  target.appendChild(result.rootEle)
51
51
  }
52
52
  const root = createRoot(result.rootEle)
53
- root.render(<AppContext.Root>{option.reactNode}</AppContext.Root>)
53
+ root.render(
54
+ <AppContext.Root classNameSpace={classNameSpace}>{option.reactNode}</AppContext.Root>
55
+ )
54
56
  result.result = true
55
57
  return result
56
58
  }
@@ -1,5 +1,3 @@
1
- import '@/entrypoints/content/global.css'
2
-
3
1
  export default function Home() {
4
2
  return <></>
5
3
  }
@@ -2,7 +2,6 @@ import { StrictMode } from 'react'
2
2
  import { createRoot } from 'react-dom/client'
3
3
  import { AppContext } from '@/shared/components'
4
4
  import Popup from './popup'
5
- import './global.css'
6
5
 
7
6
  createRoot(document.getElementById('root') as HTMLElement).render(
8
7
  <StrictMode>
@@ -4,7 +4,7 @@
4
4
  "version": "0.0.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
- "prepare": "husky install",
7
+ "prepare": "husky",
8
8
  "dev": "wxt",
9
9
  "dev:firefox": "wxt -b firefox",
10
10
  "build": "wxt build",
@@ -25,8 +25,9 @@
25
25
  "commit": "git add . && npm run cz"
26
26
  },
27
27
  "dependencies": {
28
+ "@emotion/react": "11.14.0",
29
+ "@emotion/styled": "11.14.1",
28
30
  "@tanstack/react-query": "5.51.15",
29
- "@vanilla-extract/css": "1.17.4",
30
31
  "@webext-core/messaging": "2.2.0",
31
32
  "axios": "1.7.9",
32
33
  "define-zustand": "3.4.0",
@@ -42,13 +43,13 @@
42
43
  "@commitlint/cli": "17.6.1",
43
44
  "@commitlint/config-conventional": "17.6.1",
44
45
  "@commitlint/cz-commitlint": "17.5.0",
46
+ "@emotion/babel-plugin": "11.13.5",
45
47
  "@eslint/js": "9.15.0",
46
48
  "@types/chrome": "0.0.254",
47
49
  "@types/node": "18.16.0",
48
50
  "@types/qs": "6.9.7",
49
51
  "@types/react": "18.3.3",
50
52
  "@types/react-dom": "18.3.0",
51
- "@vanilla-extract/vite-plugin": "5.1.1",
52
53
  "@vitejs/plugin-react": "5.0.1",
53
54
  "autoprefixer": "10.4.14",
54
55
  "commitizen": "4.3.0",
@@ -1,10 +1,19 @@
1
1
  import { FunctionComponent, ReactNode } from 'react'
2
2
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
3
+ import { Global, ThemeProvider } from '@emotion/react'
4
+ import { createGlobalCss, theme } from '@/shared/styles'
3
5
 
4
6
  const queryClient = new QueryClient()
5
7
 
6
- const AppContext: FunctionComponent<{ children: ReactNode }> = props => {
7
- return <QueryClientProvider client={queryClient}>{props.children}</QueryClientProvider>
8
+ const AppContext: FunctionComponent<{ children: ReactNode; classNameSpace?: string }> = props => {
9
+ return (
10
+ <ThemeProvider theme={theme}>
11
+ <QueryClientProvider client={queryClient}>
12
+ <Global styles={createGlobalCss(props.classNameSpace)} />
13
+ {props.children}
14
+ </QueryClientProvider>
15
+ </ThemeProvider>
16
+ )
8
17
  }
9
18
 
10
19
  export default AppContext
@@ -0,0 +1,9 @@
1
+ import { css } from '@emotion/react'
2
+
3
+ export const createGlobalCss = (nameSpace?: string) => {
4
+ return css`
5
+ ${nameSpace ? `.${nameSpace} ` : 'body'} {
6
+ margin: 0;
7
+ }
8
+ `
9
+ }
@@ -1,2 +1,2 @@
1
- export * from './global.css'
2
- export * from './theme.css'
1
+ export * from './global'
2
+ export * from './theme'
@@ -0,0 +1,60 @@
1
+ import { CSSProperties } from 'react'
2
+ import { isString } from 'es-toolkit'
3
+ import { isNumber } from 'es-toolkit/compat'
4
+
5
+ export const theme = {
6
+ text: {
7
+ xs: { fontSize: '12px', lineHeight: '20px' },
8
+ sm: { fontSize: '14px', lineHeight: '22px' },
9
+ base: { fontSize: '16px', lineHeight: '24px' },
10
+ lg: { fontSize: '18px', lineHeight: '26px' },
11
+ xl: { fontSize: '20px', lineHeight: '28px' },
12
+ '2xl': { fontSize: '24px', lineHeight: '32px' },
13
+ '3xl': { fontSize: '28px', lineHeight: '40px' },
14
+ '4xl': { fontSize: '32px', lineHeight: '44px' }
15
+ } satisfies Record<string, CSSProperties>,
16
+ tools: {
17
+ ellipsis: () => ({
18
+ overflow: 'hidden',
19
+ textOverflow: 'ellipsis',
20
+ whiteSpace: 'nowrap'
21
+ }),
22
+ lineClamp: (n: number) => ({
23
+ '-webkit-line-clamp': `${n}`,
24
+ '-webkit-box-orient': 'vertical',
25
+ overflow: 'hidden',
26
+ display: '-webkit-box'
27
+ }),
28
+ size: (s: string) => ({ width: s, height: s }),
29
+ py: (s: string) => ({ paddingTop: s, paddingBottom: s }),
30
+ px: (s: string) => ({ paddingLeft: s, paddingRight: s }),
31
+ my: (s: string) => ({ marginTop: s, marginBottom: s }),
32
+ mx: (s: string) => ({ marginLeft: s, marginRight: s }),
33
+ flex: (
34
+ align: CSSProperties['alignItems'],
35
+ justify: CSSProperties['justifyContent'],
36
+ vertical?: boolean
37
+ ) => {
38
+ return {
39
+ display: 'flex',
40
+ alignItems: align,
41
+ justifyContent: justify,
42
+ flexDirection: vertical ? 'column' : 'row'
43
+ } satisfies CSSProperties
44
+ },
45
+ /** 数字为元素数量,字符串为对应css的值 */
46
+ grid: (
47
+ rows: number | CSSProperties['gridTemplateRows'],
48
+ cols: number | CSSProperties['gridTemplateColumns'],
49
+ gap?: number | string
50
+ ) => {
51
+ return {
52
+ display: 'grid',
53
+ gridTemplateRows: isString(rows) ? rows : `repeat(${rows}, minmax(0, 1fr))`,
54
+ gridTemplateColumns: isString(cols) ? cols : `repeat(${cols}, minmax(0, 1fr))`,
55
+ gap: isNumber(gap) ? `${gap}px` : gap
56
+ } satisfies CSSProperties
57
+ }
58
+ }
59
+ }
60
+ export type themeType = typeof theme
@@ -18,6 +18,7 @@
18
18
  "isolatedModules": true,
19
19
  "noEmit": true,
20
20
  "jsx": "react-jsx",
21
+ "jsxImportSource": "@emotion/react",
21
22
  "paths": {
22
23
  "@/*": ["./*"]
23
24
  }
@@ -1,5 +1,7 @@
1
1
  /// <reference types="vite/client" />
2
2
  /// <reference types="./.wxt/wxt.d.ts" />
3
+ import '@emotion/react'
4
+ import { type themeType } from '@/shared/styles'
3
5
 
4
6
  declare global {
5
7
  interface ImportMetaEnv {
@@ -12,3 +14,7 @@ declare global {
12
14
  readonly env: ImportMetaEnv
13
15
  }
14
16
  }
17
+
18
+ declare module '@emotion/react' {
19
+ export interface Theme extends themeType {}
20
+ }
@@ -1,7 +1,6 @@
1
1
  import { defineConfig, UserManifestFn } from 'wxt'
2
2
  import react from '@vitejs/plugin-react'
3
3
  import svgr from 'vite-plugin-svgr'
4
- import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'
5
4
  import pkgJson from './package.json'
6
5
 
7
6
  const manifest: UserManifestFn = () => {
@@ -30,7 +29,14 @@ export default defineConfig({
30
29
  runner: { disabled: true },
31
30
  imports: { eslintrc: { enabled: 9 } },
32
31
  vite: ({ mode }) => ({
33
- plugins: [vanillaExtractPlugin(), svgr(), react()] as any,
32
+ plugins: [
33
+ svgr(),
34
+ react({
35
+ babel: {
36
+ plugins: ['@emotion']
37
+ }
38
+ })
39
+ ] as any,
34
40
  resolve: {
35
41
  alias: {
36
42
  '@': __dirname
@@ -1,5 +0,0 @@
1
- import { globalStyle } from '@vanilla-extract/css'
2
-
3
- globalStyle('body', {
4
- margin: 0
5
- })
@@ -1,7 +0,0 @@
1
- import { style } from '@vanilla-extract/css'
2
-
3
- export const root = style({
4
- display: 'flex',
5
- alignItems: 'center',
6
- justifyContent: 'center'
7
- })
@@ -1,3 +0,0 @@
1
- import { createTheme } from '@vanilla-extract/css'
2
-
3
- export const [themeClass, themeVars] = createTheme({})
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npm run lint
@@ -1,5 +0,0 @@
1
- import { globalStyle } from '@vanilla-extract/css'
2
-
3
- globalStyle('body', {
4
- margin: 0
5
- })
@@ -1,7 +0,0 @@
1
- import { style } from '@vanilla-extract/css'
2
-
3
- export const root = style({
4
- display: 'flex',
5
- alignItems: 'center',
6
- justifyContent: 'center'
7
- })
@@ -1,3 +0,0 @@
1
- import { createTheme } from '@vanilla-extract/css'
2
-
3
- export const [themeClass, themeVars] = createTheme({})
@@ -1,5 +0,0 @@
1
- import { globalStyle } from '@vanilla-extract/css'
2
- import { createGlobalStyle } from '@/shared/styles'
3
- import { classNameSpace } from './constants'
4
-
5
- globalStyle(classNameSpace, createGlobalStyle())
@@ -1,4 +0,0 @@
1
- import { globalStyle } from '@vanilla-extract/css'
2
- import { createGlobalStyle } from '@/shared/styles'
3
-
4
- globalStyle('body', createGlobalStyle())
@@ -1,7 +0,0 @@
1
- import { GlobalStyleRule } from '@vanilla-extract/css'
2
-
3
- export function createGlobalStyle(): GlobalStyleRule {
4
- return {
5
- margin: 0
6
- }
7
- }
@@ -1,3 +0,0 @@
1
- import { createTheme } from '@vanilla-extract/css'
2
-
3
- export const [themeClass, themeVars] = createTheme({})