@variousjs/create 2.0.1 → 3.0.0

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 (59) hide show
  1. package/.eslintignore +1 -1
  2. package/.gitignore.copy +1 -0
  3. package/components.json +17 -0
  4. package/package-lock.json.copy +9270 -3780
  5. package/package.json +31 -17
  6. package/package.json.copy +29 -15
  7. package/public/dist/app.js +2 -0
  8. package/public/dist/app.js.map +1 -0
  9. package/public/dist/card.js +2 -0
  10. package/public/dist/card.js.map +1 -0
  11. package/public/dist/next.js +2 -0
  12. package/public/dist/next.js.map +1 -0
  13. package/public/dist/shadcn-ui.js +2 -0
  14. package/public/dist/shadcn-ui.js.map +1 -0
  15. package/public/dist/top.js +2 -0
  16. package/public/dist/top.js.map +1 -0
  17. package/public/globals.css +1 -0
  18. package/public/index.html +49 -0
  19. package/src/{entry → components/app}/actions.ts +2 -2
  20. package/src/components/app/container.less +33 -0
  21. package/src/{entry → components/app}/container.tsx +17 -20
  22. package/src/components/app/error.tsx +14 -0
  23. package/src/components/app/index.ts +16 -0
  24. package/src/{entry → components/app}/loader.tsx +1 -2
  25. package/src/components/card/index.tsx +42 -0
  26. package/src/components/next/index.tsx +54 -0
  27. package/src/components/top/index.tsx +29 -0
  28. package/src/declaration.d.ts +0 -26
  29. package/src/index.html +15 -0
  30. package/src/shadcn-ui/components/ui/button.tsx +57 -0
  31. package/src/shadcn-ui/globals.css +76 -0
  32. package/src/shadcn-ui/index.ts +1 -0
  33. package/src/shadcn-ui/lib/utils.ts +6 -0
  34. package/src/types.ts +2 -2
  35. package/tailwind.config.js +134 -0
  36. package/tsconfig.json +6 -2
  37. package/various.config.js +86 -0
  38. package/webpack/{entry.js → app.js} +2 -2
  39. package/webpack/base.js +28 -39
  40. package/webpack/component.js +2 -2
  41. package/demo/dist/card.js +0 -2
  42. package/demo/dist/card.js.map +0 -1
  43. package/demo/dist/entry.js +0 -2
  44. package/demo/dist/entry.js.map +0 -1
  45. package/demo/dist/next.js +0 -2
  46. package/demo/dist/next.js.map +0 -1
  47. package/demo/dist/top.js +0 -2
  48. package/demo/dist/top.js.map +0 -1
  49. package/demo/index.html +0 -62
  50. package/src/components/card.less +0 -3
  51. package/src/components/card.tsx +0 -52
  52. package/src/components/next.tsx +0 -49
  53. package/src/components/top.tsx +0 -55
  54. package/src/entry/entry.less +0 -9
  55. package/src/entry/error.tsx +0 -19
  56. package/src/entry/index.ts +0 -5
  57. /package/src/{entry → components/app}/store.ts +0 -0
  58. /package/src/components/{i18n → next/i18n}/en.json +0 -0
  59. /package/src/components/{i18n → next/i18n}/zh.json +0 -0
@@ -0,0 +1,42 @@
1
+ import React from 'react'
2
+ import { ComponentNode } from '@variousjs/various'
3
+ import { useParams } from 'react-router-dom'
4
+ import { Button } from 'shadcn-ui'
5
+ import { Store } from '../../types'
6
+
7
+ const H = ((props) => {
8
+ const { id } = useParams<{ id: string }>()
9
+
10
+ return (
11
+ <>
12
+ <h3>Card</h3>
13
+ <p>Route params: {id || 'empty'}</p>
14
+ <div className="flex justify-between">
15
+ <Button
16
+ onClick={() => props.$dispatch('next', 'setValue', 1)}
17
+ variant="secondary"
18
+ >
19
+ Value
20
+ </Button>
21
+ <Button
22
+ variant="outline"
23
+ onClick={() => props.$dispatch('app', 'setLocale', props.$store.locale === 'zh' ? 'en' : 'zh')}
24
+ >
25
+ Locale
26
+ </Button>
27
+ <Button
28
+ onClick={async () => {
29
+ const a = `${Math.random().toFixed(2)}`
30
+ await props.$dispatch('app', 'setName', a)
31
+ }}
32
+ >
33
+ Store
34
+ </Button>
35
+ </div>
36
+ </>
37
+ )
38
+ }) as ComponentNode<Store>
39
+
40
+ H.logName = () => alert('Card')
41
+
42
+ export default H
@@ -0,0 +1,54 @@
1
+ import React, { Component } from 'react'
2
+ import { ComponentProps, Nycticorax, Invoker, I18n } from '@variousjs/various'
3
+ import { Button } from 'shadcn-ui'
4
+ import { Store } from '../../types'
5
+ import zh from './i18n/zh.json'
6
+ import en from './i18n/en.json'
7
+
8
+ type S = { value: number }
9
+
10
+ const {
11
+ createStore,
12
+ connect,
13
+ emit,
14
+ getStore,
15
+ } = new Nycticorax<S>()
16
+
17
+ createStore({ value: 0 })
18
+
19
+ class X extends Component<S & ComponentProps<Store>> {
20
+ static setValue: Invoker = async (value) => {
21
+ const store = getStore()
22
+ emit({ value: value + store.value }, true)
23
+ }
24
+
25
+ static $i18n: I18n = () => ({
26
+ localeKey: 'locale',
27
+ resources: { zh, en },
28
+ })
29
+
30
+ render() {
31
+ const { user } = this.props.$store
32
+ const { value, $t, $dispatch } = this.props
33
+
34
+ return (
35
+ <>
36
+ <h3>Next</h3>
37
+ <div>
38
+ <ul className="list-disc">
39
+ <li>Store: {user.name}</li>
40
+ <li>Value: {value}</li>
41
+ <li>Locale: {$t('title', { name: 'various' })}</li>
42
+ </ul>
43
+ <Button
44
+ onClick={() => $dispatch('card', 'logName')}
45
+ >
46
+ Name
47
+ </Button>
48
+ </div>
49
+ </>
50
+ )
51
+ }
52
+ }
53
+
54
+ export default connect('value')(X)
@@ -0,0 +1,29 @@
1
+ import React, { FC } from 'react'
2
+ import { ComponentProps, getConfig, ComponentNode } from '@variousjs/various'
3
+ import { useNavigate } from 'react-router-dom'
4
+ import { Config, Store } from '../../types'
5
+
6
+ export const H: FC<ComponentProps<Store>> = () => {
7
+ const $config = getConfig() as Config
8
+ const navigate = useNavigate()
9
+
10
+ const onRouterChange = (p: string) => {
11
+ navigate(p)
12
+ }
13
+
14
+ return (
15
+ <div className="flex justify-between gap-10">
16
+ {$config.links.map(({ path, name }) => (
17
+ <div className="border-solid cursor-pointer rounded py-0.5 px-2 border-2 border-sky-500" onClick={() => onRouterChange(path)} key={path}>
18
+ {name}
19
+ </div>
20
+ ))}
21
+ </div>
22
+ )
23
+ }
24
+
25
+ export const S = ((props) => {
26
+ return (
27
+ <div>Srore: {props.$store.user.name}</div>
28
+ )
29
+ }) as ComponentNode<Store>
@@ -1,29 +1,3 @@
1
- // 这里直接配置 antd 依赖库,因为 antd 是 amd 依赖进来并不参与打包
2
- // 不过也可以直接安装 antd 依赖,但只是用了 typescript 提示
3
- declare module 'antd' {
4
- import { ComponentType, Component } from 'react'
5
-
6
- export const Spin: ComponentType<any>
7
- export const Badge: ComponentType<any>
8
- export const Alert: ComponentType<any>
9
- export const Button: ComponentType<any>
10
- export class Radio extends Component<any> {
11
- static Group: ComponentType<any>
12
- static Button: ComponentType<any>
13
- }
14
- export class Card extends Component<any> {
15
- static Meta: ComponentType<any>
16
- }
17
-
18
- export class Descriptions extends Component<any> {
19
- static Item: ComponentType<any>
20
- }
21
-
22
- export const message: {
23
- info: (i: string) => void
24
- }
25
- }
26
-
27
1
  declare module '*.less' {
28
2
  const resource: Record<string, string>
29
3
  export = resource
package/src/index.html ADDED
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title> VariousJS </title>
6
+ <link rel="stylesheet" href="./globals.css" />
7
+ <script>
8
+ var VARIOUS_CONFIG = <%= htmlWebpackPlugin.options.config %>
9
+ </script>
10
+ </head>
11
+ <body>
12
+ <div id="root"></div>
13
+ <script src="https://cdn.jsdelivr.net/npm/@variousjs/various@4.0.0/dist/loader.js"></script>
14
+ </body>
15
+ </html>
@@ -0,0 +1,57 @@
1
+ import * as React from "react"
2
+ import { Slot } from "@radix-ui/react-slot"
3
+ import { cva, type VariantProps } from "class-variance-authority"
4
+
5
+ import { cn } from "@/lib/utils"
6
+
7
+ const buttonVariants = cva(
8
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default:
13
+ "bg-primary text-primary-foreground shadow hover:bg-primary/90",
14
+ destructive:
15
+ "bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
16
+ outline:
17
+ "border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
18
+ secondary:
19
+ "bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
20
+ ghost: "hover:bg-accent hover:text-accent-foreground",
21
+ link: "text-primary underline-offset-4 hover:underline",
22
+ },
23
+ size: {
24
+ default: "h-9 px-4 py-2",
25
+ sm: "h-8 rounded-md px-3 text-xs",
26
+ lg: "h-10 rounded-md px-8",
27
+ icon: "h-9 w-9",
28
+ },
29
+ },
30
+ defaultVariants: {
31
+ variant: "default",
32
+ size: "default",
33
+ },
34
+ }
35
+ )
36
+
37
+ export interface ButtonProps
38
+ extends React.ButtonHTMLAttributes<HTMLButtonElement>,
39
+ VariantProps<typeof buttonVariants> {
40
+ asChild?: boolean
41
+ }
42
+
43
+ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
44
+ ({ className, variant, size, asChild = false, ...props }, ref) => {
45
+ const Comp = asChild ? Slot : "button"
46
+ return (
47
+ <Comp
48
+ className={cn(buttonVariants({ variant, size, className }))}
49
+ ref={ref}
50
+ {...props}
51
+ />
52
+ )
53
+ }
54
+ )
55
+ Button.displayName = "Button"
56
+
57
+ export { Button, buttonVariants }
@@ -0,0 +1,76 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
4
+
5
+ @layer base {
6
+ :root {
7
+ --background: 0 0% 100%;
8
+ --foreground: 222.2 84% 4.9%;
9
+
10
+ --card: 0 0% 100%;
11
+ --card-foreground: 222.2 84% 4.9%;
12
+
13
+ --popover: 0 0% 100%;
14
+ --popover-foreground: 222.2 84% 4.9%;
15
+
16
+ --primary: 222.2 47.4% 11.2%;
17
+ --primary-foreground: 210 40% 98%;
18
+
19
+ --secondary: 210 40% 96.1%;
20
+ --secondary-foreground: 222.2 47.4% 11.2%;
21
+
22
+ --muted: 210 40% 96.1%;
23
+ --muted-foreground: 215.4 16.3% 46.9%;
24
+
25
+ --accent: 210 40% 96.1%;
26
+ --accent-foreground: 222.2 47.4% 11.2%;
27
+
28
+ --destructive: 0 84.2% 60.2%;
29
+ --destructive-foreground: 210 40% 98%;
30
+
31
+ --border: 214.3 31.8% 91.4%;
32
+ --input: 214.3 31.8% 91.4%;
33
+ --ring: 222.2 84% 4.9%;
34
+
35
+ --radius: 0.5rem;
36
+ }
37
+
38
+ .dark {
39
+ --background: 222.2 84% 4.9%;
40
+ --foreground: 210 40% 98%;
41
+
42
+ --card: 222.2 84% 4.9%;
43
+ --card-foreground: 210 40% 98%;
44
+
45
+ --popover: 222.2 84% 4.9%;
46
+ --popover-foreground: 210 40% 98%;
47
+
48
+ --primary: 210 40% 98%;
49
+ --primary-foreground: 222.2 47.4% 11.2%;
50
+
51
+ --secondary: 217.2 32.6% 17.5%;
52
+ --secondary-foreground: 210 40% 98%;
53
+
54
+ --muted: 217.2 32.6% 17.5%;
55
+ --muted-foreground: 215 20.2% 65.1%;
56
+
57
+ --accent: 217.2 32.6% 17.5%;
58
+ --accent-foreground: 210 40% 98%;
59
+
60
+ --destructive: 0 62.8% 30.6%;
61
+ --destructive-foreground: 210 40% 98%;
62
+
63
+ --border: 217.2 32.6% 17.5%;
64
+ --input: 217.2 32.6% 17.5%;
65
+ --ring: 212.7 26.8% 83.9%;
66
+ }
67
+ }
68
+
69
+ @layer base {
70
+ * {
71
+ @apply border-border;
72
+ }
73
+ body {
74
+ @apply bg-background text-foreground;
75
+ }
76
+ }
@@ -0,0 +1 @@
1
+ export { Button } from '@/components/ui/button'
@@ -0,0 +1,6 @@
1
+ import { type ClassValue, clsx } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }
package/src/types.ts CHANGED
@@ -1,9 +1,9 @@
1
- import store from './entry/store'
1
+ import store from './components/app/store'
2
2
 
3
3
  export type Store = typeof store
4
4
  export type Config = {
5
5
  pages: {
6
- path: string[] | string,
6
+ path: string,
7
7
  components: string[],
8
8
  }[],
9
9
  links: {
@@ -0,0 +1,134 @@
1
+ /** @type {import('tailwindcss').Config} */
2
+ module.exports = {
3
+ darkMode: ["class"],
4
+ content: [
5
+ './src/**/*.{ts,tsx}',
6
+ ],
7
+ prefix: "",
8
+ theme: {
9
+ container: {
10
+ center: true,
11
+ padding: "2rem",
12
+ screens: {
13
+ "2xl": "1400px",
14
+ },
15
+ },
16
+ fontSize: {
17
+ xs: '12px',
18
+ sm: '14px',
19
+ base: '16px',
20
+ lg: '18px',
21
+ xl: '20px',
22
+ '2xl': '24px',
23
+ '3xl': '30px',
24
+ '4xl': '36px',
25
+ '5xl': '48px',
26
+ '6xl': '60px',
27
+ '7xl': '72px',
28
+ },
29
+ spacing: {
30
+ px: '1px',
31
+ 0: '0',
32
+ 0.5: '2px',
33
+ 1: '4px',
34
+ 1.5: '6px',
35
+ 2: '8px',
36
+ 2.5: '10px',
37
+ 3: '12px',
38
+ 3.5: '14px',
39
+ 4: '16px',
40
+ 5: '20px',
41
+ 6: '24px',
42
+ 7: '28px',
43
+ 8: '32px',
44
+ 9: '36px',
45
+ 10: '40px',
46
+ 11: '44px',
47
+ 12: '48px',
48
+ 14: '56px',
49
+ 16: '64px',
50
+ 20: '80px',
51
+ 24: '96px',
52
+ 28: '112px',
53
+ 32: '128px',
54
+ 36: '144px',
55
+ 40: '160px',
56
+ 44: '176px',
57
+ 48: '192px',
58
+ 52: '208px',
59
+ 56: '224px',
60
+ 60: '240px',
61
+ 64: '256px',
62
+ 72: '288px',
63
+ 80: '320px',
64
+ 96: '384px',
65
+ },
66
+ extend: {
67
+ lineHeight: {
68
+ 3: '12px',
69
+ 4: '16px',
70
+ 5: '20px',
71
+ 6: '24px',
72
+ 7: '28px',
73
+ 8: '32px',
74
+ 9: '36px',
75
+ 10: '40px',
76
+ },
77
+ colors: {
78
+ border: "hsl(var(--border))",
79
+ input: "hsl(var(--input))",
80
+ ring: "hsl(var(--ring))",
81
+ background: "hsl(var(--background))",
82
+ foreground: "hsl(var(--foreground))",
83
+ primary: {
84
+ DEFAULT: "hsl(var(--primary))",
85
+ foreground: "hsl(var(--primary-foreground))",
86
+ },
87
+ secondary: {
88
+ DEFAULT: "hsl(var(--secondary))",
89
+ foreground: "hsl(var(--secondary-foreground))",
90
+ },
91
+ destructive: {
92
+ DEFAULT: "hsl(var(--destructive))",
93
+ foreground: "hsl(var(--destructive-foreground))",
94
+ },
95
+ muted: {
96
+ DEFAULT: "hsl(var(--muted))",
97
+ foreground: "hsl(var(--muted-foreground))",
98
+ },
99
+ accent: {
100
+ DEFAULT: "hsl(var(--accent))",
101
+ foreground: "hsl(var(--accent-foreground))",
102
+ },
103
+ popover: {
104
+ DEFAULT: "hsl(var(--popover))",
105
+ foreground: "hsl(var(--popover-foreground))",
106
+ },
107
+ card: {
108
+ DEFAULT: "hsl(var(--card))",
109
+ foreground: "hsl(var(--card-foreground))",
110
+ },
111
+ },
112
+ borderRadius: {
113
+ lg: "var(--radius)",
114
+ md: "calc(var(--radius) - 2px)",
115
+ sm: "calc(var(--radius) - 4px)",
116
+ },
117
+ keyframes: {
118
+ "accordion-down": {
119
+ from: { height: "0" },
120
+ to: { height: "var(--radix-accordion-content-height)" },
121
+ },
122
+ "accordion-up": {
123
+ from: { height: "var(--radix-accordion-content-height)" },
124
+ to: { height: "0" },
125
+ },
126
+ },
127
+ animation: {
128
+ "accordion-down": "accordion-down 0.2s ease-out",
129
+ "accordion-up": "accordion-up 0.2s ease-out",
130
+ },
131
+ },
132
+ },
133
+ plugins: [require("tailwindcss-animate")],
134
+ }
package/tsconfig.json CHANGED
@@ -16,7 +16,11 @@
16
16
  "removeComments": true,
17
17
  "stripInternal": true,
18
18
  "resolveJsonModule": true,
19
- "strictPropertyInitialization": false
19
+ "strictPropertyInitialization": false,
20
+ "paths": {
21
+ "@/*": ["./src/shadcn-ui/*"],
22
+ "shadcn-ui": ["./src/shadcn-ui/index.ts"]
23
+ }
20
24
  },
21
- "exclude": ["dist", "docs"],
25
+ "exclude": ["dist", "docs"]
22
26
  }
@@ -0,0 +1,86 @@
1
+ const path = require('path')
2
+ const fs = require('fs')
3
+ /** @type {import('@variousjs/registry').Packages} */
4
+ const registry = require('@variousjs/registry')
5
+
6
+ const components = fs
7
+ .readdirSync(path.resolve(__dirname, './src/components'))
8
+ .reduce((prev, cur) => {
9
+ return {
10
+ ...prev,
11
+ [cur]: path.join(__dirname, `./src/components/${cur}`),
12
+ }
13
+ }, {})
14
+
15
+ const depsComponents = Object.keys(components).reduce((prev, cur) => {
16
+ return {
17
+ ...prev,
18
+ [cur]: `./dist/${cur}.js`,
19
+ }
20
+ }, {})
21
+
22
+ const externals = ['shadcn-ui']
23
+
24
+ /**
25
+ * @param {keyof typeof registry} name
26
+ */
27
+ const getPackageSrc = (name) => {
28
+ const package = registry[name]
29
+ const version = package['dist-tags'].latest
30
+ const { dist, dependencies } = package.versions[version]
31
+
32
+ if (dependencies) {
33
+ return {
34
+ ...Object.keys(dependencies)
35
+ .reduce((prev, cur) => ({ ...prev, ...getPackageSrc(cur) }), {}),
36
+ [name]: dist,
37
+ }
38
+ }
39
+ return { [name]: dist }
40
+ }
41
+
42
+ /** @type {import('@variousjs/various').Config} */
43
+ const config = {
44
+ env: 'development',
45
+ dependencies: {
46
+ ...getPackageSrc('react'),
47
+ ...getPackageSrc('react-dom'),
48
+ ...getPackageSrc('react-router-dom'),
49
+ 'shadcn-ui': './dist/shadcn-ui.js',
50
+ ...depsComponents,
51
+ },
52
+ pages: [
53
+ {
54
+ path: '/',
55
+ components: ['card', 'next']
56
+ },
57
+ {
58
+ path: '/next/:id',
59
+ components: ['card', 'next']
60
+ },
61
+ {
62
+ path: '/error',
63
+ components: ['error'],
64
+ },
65
+ ],
66
+ links: [
67
+ {
68
+ name: 'Home',
69
+ path: '/',
70
+ },
71
+ {
72
+ name: 'Next',
73
+ path: '/next/5',
74
+ },
75
+ {
76
+ name: 'Error',
77
+ path: '/error',
78
+ },
79
+ ],
80
+ }
81
+
82
+ module.exports = {
83
+ config,
84
+ components: { ...components, 'shadcn-ui': path.resolve('./src/shadcn-ui/index.ts') },
85
+ externals,
86
+ }
@@ -1,9 +1,9 @@
1
1
  const base = require('./base')
2
2
 
3
- const { entry } = base.entry
3
+ const { app } = base.entry
4
4
  const config = {
5
5
  ...base,
6
- entry: { entry },
6
+ entry: { app },
7
7
  }
8
8
 
9
9
  module.exports = config
package/webpack/base.js CHANGED
@@ -1,62 +1,51 @@
1
1
  const path = require('path')
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin')
3
+ const variousConfig = require('../various.config')
4
+
5
+ const { NODE_ENV } = process.env
2
6
 
3
7
  const config = {
8
+ plugins: [new HtmlWebpackPlugin({
9
+ template: path.resolve(__dirname, '../src/index.html'),
10
+ filename: path.resolve(__dirname, '../public/index.html'),
11
+ config: JSON.stringify(variousConfig.config, null, 2),
12
+ inject: false,
13
+ })],
4
14
  stats: 'minimal',
5
- entry: {
6
- entry: path.join(__dirname, '../src/entry'),
7
-
8
- // 组件入口定义
9
- card: path.join(__dirname, '../src/components/card.tsx'),
10
- next: path.join(__dirname, '../src/components/next.tsx'),
11
- top: path.join(__dirname, '../src/components/top.tsx'),
12
- },
15
+ entry: variousConfig.components,
13
16
  output: {
14
- path: path.resolve(__dirname, '../demo/dist'),
17
+ path: path.resolve(__dirname, '../public/dist'),
15
18
  publicPath: '/dist/',
16
19
  filename: '[name].js',
17
20
  libraryTarget: 'amd',
18
21
  },
19
22
  target: ['web', 'es5'],
20
- externals: {
21
- // 通用排除
22
- react: {
23
- root: 'React',
24
- amd: 'react',
25
- },
26
- 'react-dom/client': {
27
- root: 'ReactDOM',
28
- amd: 'react-dom',
29
- },
30
- 'react-router-dom': {
31
- root: 'ReactRouterDOM',
32
- amd: 'react-router-dom',
33
- },
34
- '@variousjs/various': {
35
- root: 'various',
36
- amd: '@variousjs/various',
37
- },
38
-
39
- // 自定义
40
- antd: {
41
- root: 'antd',
42
- amd: 'antd',
43
- },
44
- },
45
- mode: 'production',
23
+ externals: [
24
+ 'react',
25
+ 'react-dom',
26
+ 'react-dom/client',
27
+ 'react-router-dom',
28
+ '@variousjs/various',
29
+ ...variousConfig.externals,
30
+ ],
31
+ mode: NODE_ENV || 'production',
46
32
  devtool: 'source-map',
47
33
  resolve: {
48
34
  // 必须加上 .js,不然 webpack dev server 会报错找不到模块
49
35
  extensions: ['.js', '.ts', '.tsx'],
36
+ alias: {
37
+ '@': path.resolve(__dirname, '../src/shadcn-ui'),
38
+ },
50
39
  },
51
40
  devServer: {
52
41
  allowedHosts: 'all',
53
42
  port: 2333,
54
43
  host: '0.0.0.0',
55
44
  static: {
56
- directory: path.join(__dirname, '../demo'),
45
+ directory: path.join(__dirname, '../public'),
57
46
  },
58
47
  // 监听文件构建后重新刷新页面,包括 html 文件
59
- watchFiles: ['demo'],
48
+ watchFiles: ['public'],
60
49
  },
61
50
  module: {
62
51
  rules: [
@@ -74,7 +63,7 @@ const config = {
74
63
  {
75
64
  loader: 'css-loader',
76
65
  options: {
77
- sourceMap: true,
66
+ sourceMap: NODE_ENV === 'development',
78
67
  modules: {
79
68
  localIdentName: '[local]_[hash:base64:5]',
80
69
  },
@@ -83,7 +72,7 @@ const config = {
83
72
  {
84
73
  loader: 'less-loader',
85
74
  options: {
86
- sourceMap: true,
75
+ sourceMap: NODE_ENV === 'development',
87
76
  lessOptions: {
88
77
  javascriptEnabled: true,
89
78
  },