cx-chat 0.0.1 → 0.0.2
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 +1 -1
- package/vite.config.ts +88 -80
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -126,6 +126,17 @@ export default defineConfig(({ mode }) => {
|
|
|
126
126
|
const enableObfuscate =
|
|
127
127
|
isProd && String(fileEnv.BUILD_OBFUSCATE || '').trim() === 'true'
|
|
128
128
|
|
|
129
|
+
/** npm 库入口(与 build.lib 同开);库模式会 inlineDynamicImports,不可再用 manualChunks */
|
|
130
|
+
const buildAsLib = true
|
|
131
|
+
const libConfig = buildAsLib
|
|
132
|
+
? {
|
|
133
|
+
entry: path.resolve(__dirname, 'src/index.js'),
|
|
134
|
+
name: 'CxChat',
|
|
135
|
+
fileName: (format: string) => `cx-chat.${format}.js`,
|
|
136
|
+
formats: ['es', 'umd'] as ('es' | 'umd')[],
|
|
137
|
+
}
|
|
138
|
+
: undefined
|
|
139
|
+
|
|
129
140
|
return {
|
|
130
141
|
base,
|
|
131
142
|
plugins: [
|
|
@@ -166,12 +177,7 @@ export default defineConfig(({ mode }) => {
|
|
|
166
177
|
},
|
|
167
178
|
},
|
|
168
179
|
build: {
|
|
169
|
-
lib: {
|
|
170
|
-
entry: path.resolve(__dirname, 'src/index.js'),
|
|
171
|
-
name: 'CxChat',
|
|
172
|
-
fileName: (format) => `cx-chat.${format}.js`,
|
|
173
|
-
formats: ['es', 'umd'],
|
|
174
|
-
},
|
|
180
|
+
...(libConfig ? { lib: libConfig } : {}),
|
|
175
181
|
sourcemap: false,
|
|
176
182
|
/**
|
|
177
183
|
* 生产默认用 esbuild 压缩(CI 上比 Terser 快一个数量级)。
|
|
@@ -184,81 +190,83 @@ export default defineConfig(({ mode }) => {
|
|
|
184
190
|
drop: ['console', 'debugger'],
|
|
185
191
|
}
|
|
186
192
|
: undefined,
|
|
187
|
-
rollupOptions:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
assetInfo
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
193
|
+
rollupOptions: buildAsLib
|
|
194
|
+
? {}
|
|
195
|
+
: {
|
|
196
|
+
output: {
|
|
197
|
+
entryFileNames: 'assets/js/[name]-[hash].js',
|
|
198
|
+
chunkFileNames(chunkInfo) {
|
|
199
|
+
const n = String(chunkInfo.name ?? '')
|
|
200
|
+
return n.startsWith('vendor-')
|
|
201
|
+
? 'assets/lib/[name]-[hash].js'
|
|
202
|
+
: 'assets/js/[name]-[hash].js'
|
|
203
|
+
},
|
|
204
|
+
assetFileNames(assetInfo) {
|
|
205
|
+
const n = (
|
|
206
|
+
assetInfo.names?.[0] ??
|
|
207
|
+
assetInfo.name ??
|
|
208
|
+
''
|
|
209
|
+
).toLowerCase()
|
|
210
|
+
if (n.endsWith('.css')) {
|
|
211
|
+
return 'assets/css/[name]-[hash][extname]'
|
|
212
|
+
}
|
|
213
|
+
if (/\.(woff2?|ttf|otf|eot)$/.test(n)) {
|
|
214
|
+
return 'assets/font/[name]-[hash][extname]'
|
|
215
|
+
}
|
|
216
|
+
if (/\.(png|apng|jpe?g|gif|svg|webp|ico|avif)$/.test(n)) {
|
|
217
|
+
return 'assets/img/[name]-[hash][extname]'
|
|
218
|
+
}
|
|
219
|
+
return 'assets/media/[name]-[hash][extname]'
|
|
220
|
+
},
|
|
221
|
+
manualChunks(id) {
|
|
222
|
+
if (!id.includes('node_modules')) return
|
|
223
|
+
if (
|
|
224
|
+
id.includes('/react/') ||
|
|
225
|
+
id.includes('/react-dom/') ||
|
|
226
|
+
id.includes('/scheduler/')
|
|
227
|
+
) {
|
|
228
|
+
return 'vendor-react'
|
|
229
|
+
}
|
|
230
|
+
if (id.includes('/react-router/')) {
|
|
231
|
+
return 'vendor-router'
|
|
232
|
+
}
|
|
233
|
+
if (id.includes('/@emotion/')) {
|
|
234
|
+
return 'vendor-emotion'
|
|
235
|
+
}
|
|
236
|
+
if (
|
|
237
|
+
id.includes('/rc-table/') ||
|
|
238
|
+
id.includes('/rc-tree/') ||
|
|
239
|
+
id.includes('/rc-picker/') ||
|
|
240
|
+
id.includes('/rc-field-form/')
|
|
241
|
+
) {
|
|
242
|
+
return 'vendor-rc-heavy'
|
|
243
|
+
}
|
|
244
|
+
if (id.includes('/rc-')) {
|
|
245
|
+
return 'vendor-rc'
|
|
246
|
+
}
|
|
247
|
+
if (
|
|
248
|
+
id.includes('/antd/') ||
|
|
249
|
+
id.includes('/@ant-design/')
|
|
250
|
+
) {
|
|
251
|
+
return 'vendor-antd'
|
|
252
|
+
}
|
|
253
|
+
if (
|
|
254
|
+
id.includes('/i18next/') ||
|
|
255
|
+
id.includes('/react-i18next/')
|
|
256
|
+
) {
|
|
257
|
+
return 'vendor-i18n'
|
|
258
|
+
}
|
|
259
|
+
if (
|
|
260
|
+
id.includes('/crypto-js/') ||
|
|
261
|
+
id.includes('/axios/') ||
|
|
262
|
+
id.includes('/dayjs/')
|
|
263
|
+
) {
|
|
264
|
+
return 'vendor-utils'
|
|
265
|
+
}
|
|
266
|
+
return
|
|
267
|
+
},
|
|
268
|
+
},
|
|
259
269
|
},
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
270
|
},
|
|
263
271
|
}
|
|
264
272
|
})
|