sun-form-v3 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/.history/package_20240516171646.json +21 -0
  2. package/.history/package_20240516220959.json +21 -0
  3. package/.history/package_20240516221125.json +22 -0
  4. package/.history/package_20240516221133.json +22 -0
  5. package/.history/package_20240516221150.json +22 -0
  6. package/.history/packages/index_20240516170215.ts +0 -0
  7. package/.history/packages/index_20240516170240.ts +16 -0
  8. package/.history/packages/index_20240516170259.ts +16 -0
  9. package/.history/packages/index_20240516215605.ts +16 -0
  10. package/.history/packages/sy-button/index_20240516170041.vue +0 -0
  11. package/.history/packages/sy-button/index_20240516170054.vue +11 -0
  12. package/.history/packages/sy-button/index_20240516170059.ts +0 -0
  13. package/.history/packages/sy-button/index_20240516170139.ts +6 -0
  14. package/.history/packages/sy-button/index_20240516170143.ts +6 -0
  15. package/.history/packages/sy-button/index_20240516170826.vue +11 -0
  16. package/.history/packages/sy-button/index_20240516170827.vue +11 -0
  17. package/.history/packages/sy-button/index_20240516171258.ts +6 -0
  18. package/.history/packages/sy-button/index_20240516205457.ts +6 -0
  19. package/.history/packages/sy-button/index_20240516205458.ts +6 -0
  20. package/.history/packages/sy-button/index_20240516214802.vue +11 -0
  21. package/.history/src/App_20240516163625.vue +30 -0
  22. package/.history/src/App_20240516171000.vue +30 -0
  23. package/.history/src/App_20240516171003.vue +29 -0
  24. package/.history/src/App_20240516171012.vue +31 -0
  25. package/.history/src/App_20240516171045.vue +32 -0
  26. package/.history/src/App_20240516171056.vue +23 -0
  27. package/.history/src/vite-env.d_20240516163625.ts +1 -0
  28. package/.history/src/vite-env.d_20240516164812.ts +6 -0
  29. package/.history/src/vite-env.d_20240516170519.ts +6 -0
  30. package/.history/tsconfig_20240516163625.json +25 -0
  31. package/.history/tsconfig_20240516171547.json +26 -0
  32. package/.history/tsconfig_20240516171627.json +27 -0
  33. package/.history/tsconfig_20240516171733.json +26 -0
  34. package/.history/tsconfig_20240516214249.json +29 -0
  35. package/.history/tsconfig_20240516214506.json +29 -0
  36. package/.history/tsconfig_20240516214522.json +28 -0
  37. package/.history/types/vue.d_20240516214359.ts +0 -0
  38. package/.history/types/vue.d_20240516214406.ts +4 -0
  39. package/.history/types/vue.d_20240516214702.ts +6 -0
  40. package/.history/types/vue.d_20240516214737.ts +6 -0
  41. package/.history/vite.config_20240516163625.ts +7 -0
  42. package/.history/vite.config_20240516171436.ts +63 -0
  43. package/.history/vite.config_20240516171745.ts +63 -0
  44. package/.history/vite.config_20240516171816.ts +63 -0
  45. package/.history/vite.config_20240516171904.ts +63 -0
  46. package/.history/vite.config_20240516172136.ts +65 -0
  47. package/.history/vite.config_20240516172137.ts +65 -0
  48. package/.history/vite.config_20240516172206.ts +65 -0
  49. package/.history/vite.config_20240516172233.ts +65 -0
  50. package/.history/vite.config_20240516172329.ts +65 -0
  51. package/.history/vite.config_20240516205537.ts +65 -0
  52. package/.history/vite.config_20240516221534.ts +65 -0
  53. package/.vscode/extensions.json +3 -0
  54. package/README.md +9 -0
  55. package/index.html +13 -0
  56. package/package.json +23 -0
  57. package/packages/index.ts +16 -0
  58. package/packages/sy-button/index.ts +6 -0
  59. package/packages/sy-button/index.vue +11 -0
  60. package/public/vite.svg +1 -0
  61. package/src/App.vue +23 -0
  62. package/src/assets/vue.svg +1 -0
  63. package/src/components/HelloWorld.vue +38 -0
  64. package/src/main.ts +5 -0
  65. package/src/style.css +79 -0
  66. package/src/vite-env.d.ts +6 -0
  67. package/tsconfig.json +28 -0
  68. package/tsconfig.node.json +11 -0
  69. package/types/vue.d.ts +6 -0
  70. package/vite.config.ts +65 -0
@@ -0,0 +1,65 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import { resolve } from 'path';
4
+
5
+ const pathResolve = (dir: string) => {
6
+ return resolve(__dirname, '.', dir);
7
+ };
8
+ const alias: Record<string, string> = {
9
+ '@': pathResolve('./src'),
10
+ };
11
+
12
+ // https://vitejs.dev/config/
13
+ export default defineConfig({
14
+ plugins: [vue()],
15
+ base: './',
16
+ build: {
17
+ outDir: 'dist', //输出文件名称
18
+ lib: {
19
+ entry: resolve(__dirname, './packages/index.ts'), //指定组件编译入口文件
20
+ name: 'sun-form-v3',
21
+ fileName: 'sun-form-v3'
22
+ },//库编译模式配置
23
+ rollupOptions: {
24
+ external: ['vue',
25
+ // 'swiper', '@vuepic/vue-datepicker', 'qrcode'
26
+ ],
27
+ output: {
28
+ // format: 'es', // 默认es,可选 'amd' 'cjs' 'es' 'iife' 'umd' 'system'
29
+ exports: 'named',
30
+ globals: { //在UMD构建模式下为这些外部化的依赖提供一个全局变量
31
+ vue: 'Vue',
32
+ // 'vue-router': 'VueRouter', // 引入vue-router全局变量,否则router.push将无法使用
33
+ // swiper: 'Swiper',
34
+ // '@vuepic/vue-datepicker': 'VueDatePicker',
35
+ // qrcode: 'qrcode'
36
+ }
37
+ }
38
+ },
39
+ /** 设置为 false 可以禁用最小化混淆,或是用来指定使用哪种混淆器。
40
+ 默认为 Esbuild,它比 terser 快 20-40 倍,压缩率只差 1%-2%。
41
+ 注意,在 lib 模式下使用 'es' 时,build.minify 选项不会缩减空格,因为会移除掉 pure 标注,导致破坏 tree-shaking。
42
+ 当设置为 'terser' 时必须先安装 Terser。(yarn add terser -D)
43
+ */
44
+ // minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
45
+ terserOptions: { // 在打包代码时移除 console、debugger 和 注释
46
+ compress: {
47
+ /* (default: false) -- Pass true to discard calls to console.* functions.
48
+ If you wish to drop a specific function call such as console.info and/or
49
+ retain side effects from function arguments after dropping the function
50
+ call then use pure_funcs instead-++++++-
51
+ */
52
+ drop_console: true, // 生产环境时移除console
53
+ drop_debugger: true // 生产环境时移除debugger
54
+ },
55
+ format: {
56
+ comments: false // 删除注释comments
57
+ }
58
+ }
59
+ },
60
+ resolve: {
61
+ alias,
62
+ }
63
+ })
64
+
65
+
@@ -0,0 +1,65 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import { resolve } from 'path';
4
+
5
+ const pathResolve = (dir: string) => {
6
+ return resolve(__dirname, '.', dir);
7
+ };
8
+ const alias: Record<string, string> = {
9
+ '@': pathResolve('./src'),
10
+ };
11
+
12
+ // https://vitejs.dev/config/
13
+ export default defineConfig({
14
+ plugins: [vue()],
15
+ base: './',
16
+ build: {
17
+ outDir: 'dist', //输出文件名称
18
+ lib: {
19
+ entry: resolve(__dirname, './packages/index.ts'), //指定组件编译入口文件
20
+ name: 'sun-form-v3',
21
+ fileName: 'sun-form-v3'
22
+ },//库编译模式配置
23
+ rollupOptions: {
24
+ external: ['vue',
25
+ // 'swiper', '@vuepic/vue-datepicker', 'qrcode'
26
+ ],
27
+ output: {
28
+ // format: 'es', // 默认es,可选 'amd' 'cjs' 'es' 'iife' 'umd' 'system'
29
+ exports: 'named',
30
+ globals: { //在UMD构建模式下为这些外部化的依赖提供一个全局变量
31
+ vue: 'Vue',
32
+ // 'vue-router': 'VueRouter', // 引入vue-router全局变量,否则router.push将无法使用
33
+ // swiper: 'Swiper',
34
+ // '@vuepic/vue-datepicker': 'VueDatePicker',
35
+ // qrcode: 'qrcode'
36
+ }
37
+ }
38
+ },
39
+ /** 设置为 false 可以禁用最小化混淆,或是用来指定使用哪种混淆器。
40
+ 默认为 Esbuild,它比 terser 快 20-40 倍,压缩率只差 1%-2%。
41
+ 注意,在 lib 模式下使用 'es' 时,build.minify 选项不会缩减空格,因为会移除掉 pure 标注,导致破坏 tree-shaking。
42
+ 当设置为 'terser' 时必须先安装 Terser。(yarn add terser -D)
43
+ */
44
+ minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
45
+ terserOptions: { // 在打包代码时移除 console、debugger 和 注释
46
+ compress: {
47
+ /* (default: false) -- Pass true to discard calls to console.* functions.
48
+ If you wish to drop a specific function call such as console.info and/or
49
+ retain side effects from function arguments after dropping the function
50
+ call then use pure_funcs instead-++++++-
51
+ */
52
+ drop_console: true, // 生产环境时移除console
53
+ drop_debugger: true // 生产环境时移除debugger
54
+ },
55
+ format: {
56
+ comments: false // 删除注释comments
57
+ }
58
+ }
59
+ },
60
+ resolve: {
61
+ alias,
62
+ }
63
+ })
64
+
65
+
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["Vue.volar"]
3
+ }
package/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # Vue 3 + TypeScript + Vite
2
+
3
+ This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
4
+
5
+ ## Recommended Setup
6
+
7
+ - [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur
8
+
9
+ - Use [vue-tsc](https://github.com/vuejs/language-tools/tree/master/packages/tsc) for performing the same type checking from the command line, or for generating d.ts files for SFCs.
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + Vue + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="app"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
package/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "sun-form-v3",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "main": "./dist/sun-form-v3.umd.cjs",
6
+ "type": "module",
7
+ "scripts": {
8
+ "dev": "vite",
9
+ "build": "vue-tsc && vite build",
10
+ "preview": "vite preview"
11
+ },
12
+ "dependencies": {
13
+ "vue": "^3.4.21"
14
+ },
15
+ "devDependencies": {
16
+ "@types/node": "^20.12.12",
17
+ "@vitejs/plugin-vue": "^5.0.4",
18
+ "terser": "^5.31.0",
19
+ "typescript": "^5.2.2",
20
+ "vite": "^5.2.0",
21
+ "vue-tsc": "^2.0.6"
22
+ }
23
+ }
@@ -0,0 +1,16 @@
1
+ import type { App } from 'vue'
2
+ import syButton from './sy-button'
3
+
4
+ const components = [
5
+ syButton
6
+ ];
7
+
8
+ const install = (app: App): void => {
9
+ components.forEach(component => app.component(component.__name as string, component))
10
+ }
11
+ export {
12
+ syButton
13
+ }
14
+
15
+ const viteVueNode = { install };
16
+ export default viteVueNode
@@ -0,0 +1,6 @@
1
+ import type { App } from 'vue'
2
+ import comp from './index.vue';
3
+ comp.install = (app: App) => {
4
+ app.component(comp.__name as string, comp);
5
+ }
6
+ export default comp;
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <button>孙岩按钮</button>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ // import { ref,reactive } from 'vue';
7
+ defineOptions({name:"sy-button"})
8
+ </script>
9
+
10
+ <style scoped lang="scss">
11
+ </style>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/src/App.vue ADDED
@@ -0,0 +1,23 @@
1
+ <script setup lang="ts">
2
+ </script>
3
+
4
+ <template>
5
+ <sy-button></sy-button>
6
+ </template>
7
+
8
+ <style scoped>
9
+ .logo {
10
+ height: 6em;
11
+ padding: 1.5em;
12
+ will-change: filter;
13
+ transition: filter 300ms;
14
+ }
15
+
16
+ .logo:hover {
17
+ filter: drop-shadow(0 0 2em #646cffaa);
18
+ }
19
+
20
+ .logo.vue:hover {
21
+ filter: drop-shadow(0 0 2em #42b883aa);
22
+ }
23
+ </style>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="37.07" height="36" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 198"><path fill="#41B883" d="M204.8 0H256L128 220.8L0 0h97.92L128 51.2L157.44 0h47.36Z"></path><path fill="#41B883" d="m0 0l128 220.8L256 0h-51.2L128 132.48L50.56 0H0Z"></path><path fill="#35495E" d="M50.56 0L128 133.12L204.8 0h-47.36L128 51.2L97.92 0H50.56Z"></path></svg>
@@ -0,0 +1,38 @@
1
+ <script setup lang="ts">
2
+ import { ref } from 'vue'
3
+
4
+ defineProps<{ msg: string }>()
5
+
6
+ const count = ref(0)
7
+ </script>
8
+
9
+ <template>
10
+ <h1>{{ msg }}</h1>
11
+
12
+ <div class="card">
13
+ <button type="button" @click="count++">count is {{ count }}</button>
14
+ <p>
15
+ Edit
16
+ <code>components/HelloWorld.vue</code> to test HMR
17
+ </p>
18
+ </div>
19
+
20
+ <p>
21
+ Check out
22
+ <a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
23
+ >create-vue</a
24
+ >, the official Vue + Vite starter
25
+ </p>
26
+ <p>
27
+ Install
28
+ <a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
29
+ in your IDE for a better DX
30
+ </p>
31
+ <p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
32
+ </template>
33
+
34
+ <style scoped>
35
+ .read-the-docs {
36
+ color: #888;
37
+ }
38
+ </style>
package/src/main.ts ADDED
@@ -0,0 +1,5 @@
1
+ import { createApp } from 'vue'
2
+ import './style.css'
3
+ import App from './App.vue'
4
+
5
+ createApp(App).mount('#app')
package/src/style.css ADDED
@@ -0,0 +1,79 @@
1
+ :root {
2
+ font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
+ line-height: 1.5;
4
+ font-weight: 400;
5
+
6
+ color-scheme: light dark;
7
+ color: rgba(255, 255, 255, 0.87);
8
+ background-color: #242424;
9
+
10
+ font-synthesis: none;
11
+ text-rendering: optimizeLegibility;
12
+ -webkit-font-smoothing: antialiased;
13
+ -moz-osx-font-smoothing: grayscale;
14
+ }
15
+
16
+ a {
17
+ font-weight: 500;
18
+ color: #646cff;
19
+ text-decoration: inherit;
20
+ }
21
+ a:hover {
22
+ color: #535bf2;
23
+ }
24
+
25
+ body {
26
+ margin: 0;
27
+ display: flex;
28
+ place-items: center;
29
+ min-width: 320px;
30
+ min-height: 100vh;
31
+ }
32
+
33
+ h1 {
34
+ font-size: 3.2em;
35
+ line-height: 1.1;
36
+ }
37
+
38
+ button {
39
+ border-radius: 8px;
40
+ border: 1px solid transparent;
41
+ padding: 0.6em 1.2em;
42
+ font-size: 1em;
43
+ font-weight: 500;
44
+ font-family: inherit;
45
+ background-color: #1a1a1a;
46
+ cursor: pointer;
47
+ transition: border-color 0.25s;
48
+ }
49
+ button:hover {
50
+ border-color: #646cff;
51
+ }
52
+ button:focus,
53
+ button:focus-visible {
54
+ outline: 4px auto -webkit-focus-ring-color;
55
+ }
56
+
57
+ .card {
58
+ padding: 2em;
59
+ }
60
+
61
+ #app {
62
+ max-width: 1280px;
63
+ margin: 0 auto;
64
+ padding: 2rem;
65
+ text-align: center;
66
+ }
67
+
68
+ @media (prefers-color-scheme: light) {
69
+ :root {
70
+ color: #213547;
71
+ background-color: #ffffff;
72
+ }
73
+ a:hover {
74
+ color: #747bff;
75
+ }
76
+ button {
77
+ background-color: #f9f9f9;
78
+ }
79
+ }
@@ -0,0 +1,6 @@
1
+ /// <reference types="vite/client" />
2
+ declare module "*.vue" {
3
+ import type { DefineComponent } from "vue";
4
+ const vueComponent: DefineComponent<{}, {}, any>;
5
+ export default vueComponent;
6
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "module": "ESNext",
6
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "jsx": "preserve",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true
22
+
23
+ },
24
+ "include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue","packages/**/*.vue"],
25
+ "references": [{
26
+ "path": "./tsconfig.node.json"
27
+ }]
28
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true,
8
+ "strict": true
9
+ },
10
+ "include": ["vite.config.ts"]
11
+ }
package/types/vue.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ /// <reference types="vite/client" />
2
+ declare module "*.vue" {
3
+ import type { DefineComponent } from "vue";
4
+ const vueComponent: DefineComponent<{}, {}, any>;
5
+ export default vueComponent;
6
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,65 @@
1
+ import { defineConfig } from 'vite'
2
+ import vue from '@vitejs/plugin-vue'
3
+ import { resolve } from 'path';
4
+
5
+ const pathResolve = (dir: string) => {
6
+ return resolve(__dirname, '.', dir);
7
+ };
8
+ const alias: Record<string, string> = {
9
+ '@': pathResolve('./src'),
10
+ };
11
+
12
+ // https://vitejs.dev/config/
13
+ export default defineConfig({
14
+ plugins: [vue()],
15
+ base: './',
16
+ build: {
17
+ outDir: 'dist', //输出文件名称
18
+ lib: {
19
+ entry: resolve(__dirname, './packages/index.ts'), //指定组件编译入口文件
20
+ name: 'sun-form-v3',
21
+ fileName: 'sun-form-v3'
22
+ },//库编译模式配置
23
+ rollupOptions: {
24
+ external: ['vue',
25
+ // 'swiper', '@vuepic/vue-datepicker', 'qrcode'
26
+ ],
27
+ output: {
28
+ // format: 'es', // 默认es,可选 'amd' 'cjs' 'es' 'iife' 'umd' 'system'
29
+ exports: 'named',
30
+ globals: { //在UMD构建模式下为这些外部化的依赖提供一个全局变量
31
+ vue: 'Vue',
32
+ // 'vue-router': 'VueRouter', // 引入vue-router全局变量,否则router.push将无法使用
33
+ // swiper: 'Swiper',
34
+ // '@vuepic/vue-datepicker': 'VueDatePicker',
35
+ // qrcode: 'qrcode'
36
+ }
37
+ }
38
+ },
39
+ /** 设置为 false 可以禁用最小化混淆,或是用来指定使用哪种混淆器。
40
+ 默认为 Esbuild,它比 terser 快 20-40 倍,压缩率只差 1%-2%。
41
+ 注意,在 lib 模式下使用 'es' 时,build.minify 选项不会缩减空格,因为会移除掉 pure 标注,导致破坏 tree-shaking。
42
+ 当设置为 'terser' 时必须先安装 Terser。(yarn add terser -D)
43
+ */
44
+ minify: 'terser', // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效
45
+ terserOptions: { // 在打包代码时移除 console、debugger 和 注释
46
+ compress: {
47
+ /* (default: false) -- Pass true to discard calls to console.* functions.
48
+ If you wish to drop a specific function call such as console.info and/or
49
+ retain side effects from function arguments after dropping the function
50
+ call then use pure_funcs instead-++++++-
51
+ */
52
+ drop_console: true, // 生产环境时移除console
53
+ drop_debugger: true // 生产环境时移除debugger
54
+ },
55
+ format: {
56
+ comments: false // 删除注释comments
57
+ }
58
+ }
59
+ },
60
+ resolve: {
61
+ alias,
62
+ }
63
+ })
64
+
65
+