@dxtmisha/configuration 0.3.11 → 0.4.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dxtmisha/configuration",
3
3
  "private": false,
4
- "version": "0.3.11",
4
+ "version": "0.4.0",
5
5
  "type": "module",
6
6
  "description": "Shared configuration files for DXT UI - Vite configs and TypeScript configs for building UI components",
7
7
  "keywords": [
@@ -26,8 +26,8 @@
26
26
  "url": "https://github.com/dxtmisha/dxt-ui/issues"
27
27
  },
28
28
  "files": [
29
- "viteconfig/",
30
29
  "tsconfig/",
30
+ "viteconfig/",
31
31
  "README.md",
32
32
  "package.json",
33
33
  "LICENSE"
@@ -49,6 +49,10 @@
49
49
  "types": "./viteconfig/viteFlags.config.d.ts",
50
50
  "default": "./viteconfig/viteFlags.config.js"
51
51
  },
52
+ "./viteLibraries": {
53
+ "types": "./viteconfig/viteLibraries.config.d.ts",
54
+ "default": "./viteconfig/viteLibraries.config.js"
55
+ },
52
56
  "./viteMdx": {
53
57
  "types": "./viteconfig/viteMdx.config.d.ts",
54
58
  "default": "./viteconfig/viteMdx.config.js"
@@ -59,8 +63,8 @@
59
63
  "node": ">=18.0.0"
60
64
  },
61
65
  "peerDependencies": {
62
- "vite": ">=4.0.0",
63
- "typescript": ">=4.5.0"
66
+ "vite": "*",
67
+ "typescript": "*"
64
68
  },
65
69
  "dependencies": {}
66
70
  }
@@ -3,6 +3,9 @@ import { defineConfig } from 'vite'
3
3
  import vue from '@vitejs/plugin-vue'
4
4
  import dts from 'vite-plugin-dts'
5
5
 
6
+ import autoprefixer from 'autoprefixer'
7
+ import cssnanoPlugin from 'cssnano'
8
+
6
9
  // https://vite.dev/config/
7
10
 
8
11
  /**
@@ -10,30 +13,26 @@ import dts from 'vite-plugin-dts'
10
13
  *
11
14
  * Создаёт базовую конфигурацию Vite для библиотек с функциями/композаблами/классами.
12
15
  * @param name global library name / глобальное имя библиотеки
16
+ * @param target build target / цель сборки
13
17
  * @param entry entry points / входные точки сборки
14
18
  * @param include glob patterns for d.ts / паттерны для генерации d.ts
15
19
  * @param includeExtended extra patterns / дополнительные паттерны
16
20
  * @param external external dependencies / внешние зависимости
17
21
  * @param externalExtended extra dependencies / дополнительные зависимости
22
+ * @param fileCssName name of the output CSS file / имя выходного CSS файла
23
+ * @param rollupTypes whether to use rollupTypes in dts plugin / использовать ли rollupTypes в плагине dts
18
24
  * @returns Vite config / конфигурация Vite
19
25
  */
20
26
  export const viteBasicFunction = (
21
27
  name = 'dxt-ui',
28
+ target = 'es2018',
22
29
  entry = [
23
30
  'src/library.ts'
24
31
  ],
25
32
  include = [
26
- 'src/classes/**/*.ts',
27
- 'src/composables/**/*.ts',
28
- 'src/documentation/**/*.ts',
29
- 'src/documentation/**/*.tsx',
30
- 'src/functions/**/*.ts',
31
- 'src/media/**/*.ts',
32
- 'src/types/**/*.ts',
33
- 'src/flags.ts',
34
- 'src/library.ts',
35
- 'src/media.ts',
36
- 'src/storybook.tsx'
33
+ 'src/**/*.ts',
34
+ 'src/**/*.tsx',
35
+ 'src/**/*.vue'
37
36
  ],
38
37
  includeExtended = [],
39
38
  external = [
@@ -58,9 +57,12 @@ export const viteBasicFunction = (
58
57
  '@emotion/react',
59
58
  '@emotion/styled'
60
59
  ],
61
- externalExtended = []
60
+ externalExtended = [],
61
+ fileCssName = 'style.css',
62
+ rollupTypes = false
62
63
  ) => defineConfig({
63
64
  build: {
65
+ target,
64
66
  lib: {
65
67
  entry,
66
68
  name,
@@ -79,20 +81,59 @@ export const viteBasicFunction = (
79
81
  ]
80
82
 
81
83
  return externalsList.some(ext => id === ext || id.startsWith(ext + '/'))
84
+ },
85
+ output: {
86
+ assetFileNames: (assetInfo) => {
87
+ const fileName = assetInfo.names?.[0] || assetInfo.originalFileName
88
+
89
+ if (
90
+ fileCssName
91
+ && fileName
92
+ && fileName.endsWith('.css')
93
+ ) {
94
+ return fileCssName
95
+ }
96
+
97
+ return '[name]-[hash][extname]'
98
+ }
82
99
  }
83
100
  }
84
101
  },
102
+ css: {
103
+ postcss: {
104
+ plugins: [
105
+ autoprefixer(),
106
+ cssnanoPlugin({ preset: 'default' })
107
+ ]
108
+ }
109
+ },
85
110
  plugins: [
86
111
  vue(),
87
112
  dts({
88
113
  clearPureImport: false,
89
- copyDtsFiles: true,
114
+ copyDtsFiles: false,
115
+ exclude: [
116
+ '**/__tests__/**',
117
+ '**/*.test.ts',
118
+ '**/*.spec.ts',
119
+ '**/*.stories.ts',
120
+ '**/*.stories.tsx',
121
+ '**/*.json',
122
+ '**/node_modules/**',
123
+ '**/dist/**',
124
+ '**/dist-temporary/**',
125
+ '**/*.config.ts',
126
+ '**/*.config.js',
127
+ '**/vite-env.d.ts'
128
+ ],
90
129
  include: [
130
+ ...entry,
91
131
  ...include,
92
132
  ...includeExtended
93
133
  ],
94
134
  insertTypesEntry: true,
95
135
  outDir: 'dist',
136
+ rollupTypes,
96
137
  staticImport: true,
97
138
  tsconfigPath: './tsconfig.app.json'
98
139
  })
@@ -1,7 +1,8 @@
1
- import nodePath from 'node:path'
1
+ // import nodePath from 'node:path'
2
2
  import { defineConfig } from 'vite'
3
3
 
4
4
  import vue from '@vitejs/plugin-vue'
5
+ import dts from 'vite-plugin-dts'
5
6
 
6
7
  /**
7
8
  * Creates a base Vite config for libraries with only Vue components.
@@ -15,11 +16,11 @@ export const viteComponentOnly = (
15
16
  path,
16
17
  packages
17
18
  ) => {
18
- return defineConfig({
19
- plugins: [vue()],
19
+ const outDir = 'dist-temporary'
20
20
 
21
+ return defineConfig({
21
22
  build: {
22
- outDir: nodePath.join(nodePath.dirname(path), 'wiki', 'temporary', 'dist'),
23
+ outDir,
23
24
 
24
25
  lib: {
25
26
  entry: path,
@@ -46,6 +47,37 @@ export const viteComponentOnly = (
46
47
  alias: {
47
48
  '@': packages
48
49
  }
49
- }
50
+ },
51
+
52
+ plugins: [
53
+ vue()/* ,
54
+ dts({
55
+ clearPureImport: false,
56
+ copyDtsFiles: true,
57
+ insertTypesEntry: true,
58
+ outDir,
59
+ include: [
60
+ 'src/!**!/!*.ts',
61
+ 'src/!**!/!*.tsx',
62
+ 'src/!**!/!*.vue'
63
+ ],
64
+ exclude: [
65
+ '**!/__tests__/!**',
66
+ '**!/!*.test.ts',
67
+ '**!/!*.spec.ts',
68
+ '**!/!*.stories.ts',
69
+ '**!/!*.stories.tsx',
70
+ '**!/!*.json',
71
+ '**!/node_modules/!**',
72
+ '**!/dist/!**',
73
+ '**!/dist-temporary/!**',
74
+ '**!/!*.config.ts',
75
+ '**!/!*.config.js',
76
+ '**!/vite-env.d.ts'
77
+ ],
78
+ staticImport: true,
79
+ tsconfigPath: './tsconfig.app.json'
80
+ }) */
81
+ ]
50
82
  })
51
83
  }
@@ -0,0 +1 @@
1
+ export declare const viteLibraries: {}
@@ -0,0 +1,27 @@
1
+ import fs from 'node:fs'
2
+ import path from 'node:path'
3
+ import { fileURLToPath } from 'node:url'
4
+
5
+ import { viteBasicFunction } from './viteBasicFunction.config.js'
6
+
7
+ const __filename = fileURLToPath(import.meta.url)
8
+ const __dirname = path.dirname(__filename)
9
+
10
+ // https://vite.dev/config/
11
+ export const viteLibraries = viteBasicFunction(
12
+ undefined,
13
+ undefined,
14
+ [
15
+ ...(() => {
16
+ const dir = path.resolve(__dirname, 'src/library')
17
+
18
+ if (fs.existsSync(dir)) {
19
+ return fs.readdirSync(dir)
20
+ .filter(file => file.endsWith('.ts'))
21
+ .map(file => path.join(dir, file))
22
+ }
23
+
24
+ return []
25
+ })()
26
+ ]
27
+ )