create-packer 1.35.2 → 1.35.4

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,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.35.2",
3
+ "version": "1.35.4",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -47,7 +47,6 @@
47
47
  "@rsbuild/plugin-type-check": "1.0.1-rc.4",
48
48
  "@rsdoctor/rspack-plugin": "0.4.1",
49
49
  "@types/lodash-es": "4.17.7",
50
- "@types/mockjs": "1.0.7",
51
50
  "@types/node": "18.16.0",
52
51
  "@types/qs": "6.9.7",
53
52
  "@types/react": "18.3.3",
@@ -1,4 +1,4 @@
1
- import { defineConfig, loadEnv, RsbuildConfig } from '@rsbuild/core'
1
+ import { defineConfig, loadEnv, RsbuildConfig, CacheGroups } from '@rsbuild/core'
2
2
  import { pluginReact } from '@rsbuild/plugin-react'
3
3
  import { pluginStyledComponents } from '@rsbuild/plugin-styled-components'
4
4
  import { pluginEslint } from '@rsbuild/plugin-eslint'
@@ -7,7 +7,30 @@ import { pluginTypeCheck } from '@rsbuild/plugin-type-check'
7
7
  import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
8
8
  import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
9
9
 
10
- export default defineConfig(({ envMode }) => {
10
+ function createChunks(chunks: Array<{ name: string; libs: string[] | RegExp; priority?: number }>) {
11
+ const result: CacheGroups = {
12
+ vendors: {
13
+ test: /[\\/]node_modules[\\/]/,
14
+ chunks: 'all',
15
+ name: 'vendors',
16
+ priority: -1
17
+ }
18
+ }
19
+ chunks.forEach(({ name, libs, priority }) => {
20
+ result[name] = {
21
+ test: Array.isArray(libs)
22
+ ? new RegExp(`[\\\\/]node_modules[\\\\/](${libs.join('|')})[\\\\/]`)
23
+ : libs,
24
+ chunks: 'all',
25
+ name,
26
+ priority
27
+ }
28
+ return result
29
+ })
30
+ return result
31
+ }
32
+
33
+ export default defineConfig(({ envMode, command }) => {
11
34
  const { parsed: env } = loadEnv()
12
35
  const proxyBaseUrl = env.PUBLIC_BASE_URL + env.PUBLIC_API_HOST
13
36
  return {
@@ -43,23 +66,12 @@ export default defineConfig(({ envMode }) => {
43
66
  pluginReact({})
44
67
  ],
45
68
  performance: {
69
+ removeConsole: command === 'build' ? ['log'] : false,
46
70
  chunkSplit: {
47
71
  strategy: 'custom',
48
72
  splitChunks: {
49
73
  minChunks: 1,
50
- cacheGroups: {
51
- react: {
52
- test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
53
- chunks: 'all',
54
- name: 'react'
55
- },
56
- vendors: {
57
- test: /[\\/]node_modules[\\/]/,
58
- chunks: 'all',
59
- name: 'vendors',
60
- priority: -1
61
- }
62
- }
74
+ cacheGroups: createChunks([{ libs: ['react', 'react-dom'], name: 'react' }])
63
75
  }
64
76
  }
65
77
  },
@@ -39,7 +39,6 @@
39
39
  "@faker-js/faker": "8.4.1",
40
40
  "@rollup/plugin-eslint": "9.0.5",
41
41
  "@types/lodash-es": "4.17.7",
42
- "@types/mockjs": "1.0.7",
43
42
  "@types/node": "18.16.0",
44
43
  "@types/qs": "6.9.7",
45
44
  "@types/react": "18.3.3",