create-packer 1.35.3 → 1.35.5

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.3",
3
+ "version": "1.35.5",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -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'
@@ -6,8 +6,32 @@ import StylelintWebpackPlugin from 'stylelint-webpack-plugin'
6
6
  import { pluginTypeCheck } from '@rsbuild/plugin-type-check'
7
7
  import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'
8
8
  import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin'
9
+ import { pluginSvgr } from '@rsbuild/plugin-svgr'
9
10
 
10
- export default defineConfig(({ envMode }) => {
11
+ function createChunks(chunks: Array<{ name: string; libs: string[] | RegExp; priority?: number }>) {
12
+ const result: CacheGroups = {
13
+ vendors: {
14
+ test: /[\\/]node_modules[\\/]/,
15
+ chunks: 'all',
16
+ name: 'vendors',
17
+ priority: -1
18
+ }
19
+ }
20
+ chunks.forEach(({ name, libs, priority }) => {
21
+ result[name] = {
22
+ test: Array.isArray(libs)
23
+ ? new RegExp(`[\\\\/]node_modules[\\\\/](${libs.join('|')})[\\\\/]`)
24
+ : libs,
25
+ chunks: 'all',
26
+ name,
27
+ priority
28
+ }
29
+ return result
30
+ })
31
+ return result
32
+ }
33
+
34
+ export default defineConfig(({ envMode, command }) => {
11
35
  const { parsed: env } = loadEnv()
12
36
  const proxyBaseUrl = env.PUBLIC_BASE_URL + env.PUBLIC_API_HOST
13
37
  return {
@@ -40,26 +64,16 @@ export default defineConfig(({ envMode }) => {
40
64
  fileName: false,
41
65
  transpileTemplateLiterals: false
42
66
  }),
67
+ pluginSvgr(),
43
68
  pluginReact({})
44
69
  ],
45
70
  performance: {
71
+ removeConsole: command === 'build' ? ['log'] : false,
46
72
  chunkSplit: {
47
73
  strategy: 'custom',
48
74
  splitChunks: {
49
75
  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
- }
76
+ cacheGroups: createChunks([{ libs: ['react', 'react-dom'], name: 'react' }])
63
77
  }
64
78
  }
65
79
  },