yks-element 1.1.4 → 1.1.7

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.
Files changed (3) hide show
  1. package/lib/bin/pack.js +155 -114
  2. package/lib/yks.js +1 -1
  3. package/package.json +1 -1
package/lib/bin/pack.js CHANGED
@@ -10,117 +10,158 @@
10
10
  * @function setPackParams 设置打包参数
11
11
  * @function proxy 代理
12
12
  */
13
- const NPM_APP_CDN_URL = 'https://pub-static.yks365.net/assets'
14
- const NPM_APP_DEV_URL = 'https://gldev.cetset.com'
15
- const NPM_APP_TEST_URL = 'https://gltest.cetset.com'
16
- const NPM_APP_PRE_URL = 'https://glpre.yks365.net'
17
- const NPM_APP_PROD_URL = 'https://gl.yks365.net'
18
-
19
- const getConfig = () => {
20
- let cdnConfigs = [
21
- {
22
- name: 'kityformula',
23
- library: 'kityformula',
24
- js: [
25
- `${NPM_APP_CDN_URL}/tinymce/kityformula-editor/kityformula/js/jquery-3.6.0.min.js`,
26
- `${NPM_APP_CDN_URL}/tinymce/kityformula-editor/kityformula/js/kitygraph.all.js`,
27
- `${NPM_APP_CDN_URL}/tinymce/kityformula-editor/kityformula/js/kity-formula-render.all.js`,
28
- `${NPM_APP_CDN_URL}/tinymce/kityformula-editor/kityformula/js/kity-formula-parser.all.min.js`,
29
- `${NPM_APP_CDN_URL}/tinymce/kityformula-editor/kityformula/js/kityformula-editor.all.min.js`
30
- ],
31
- css: []
32
- }
33
- ]
34
- return cdnConfigs
35
- }
36
-
37
- const cdn = () => {
38
- const cdnConfig = getConfig()
39
- const js = []
40
- const css = []
41
- cdnConfig.forEach((v) => {
42
- js.push(...v.js)
43
- css.push(...v.css)
44
- })
45
- return {
46
- css,
47
- js
48
- }
49
- }
50
-
51
- const setPackParams = (config) => {
52
- config.plugin('html').tap((args) => {
53
- let cdns = cdn()
54
- args[0].cdn = cdns
55
- return args
56
- })
57
- }
58
-
59
- const proxy = (pro, env, targets) => {
60
- if (!pro || !env) {
61
- return new Error('pro or env is not difine !')
62
- }
63
- const params = {
64
- dev: NPM_APP_DEV_URL,
65
- test: NPM_APP_TEST_URL,
66
- pre: NPM_APP_PRE_URL,
67
- prod: NPM_APP_PROD_URL
68
- }
69
- const target = params[env] ? params[env] : targets
70
- return {
71
- ['/' + pro + '/bm']: {
72
- target: target,
73
- pathRewrite: { ['^/' + pro + '/bm']: `/${pro}/bm` }
74
- },
75
- ['/' + pro + '/pj']: {
76
- target: target,
77
- pathRewrite: { ['^/' + pro + '/pj']: `/${pro}/pj` }
78
- },
79
- ['/' + pro + '/ua']: {
80
- target: target,
81
- pathRewrite: { ['^/' + pro + '/ua']: `/${pro}/ua` }
82
- },
83
- ['/' + pro + '/gov']: {
84
- target: target,
85
- pathRewrite: { ['^/' + pro + '/gov']: `/${pro}/gov` }
86
- },
87
- ['/' + pro + '/kw']: {
88
- target: target,
89
- pathRewrite: { ['^/' + pro + '/kw']: `/${pro}/kw` }
90
- },
91
- ['/' + pro + '/pt']: {
92
- target: target,
93
- pathRewrite: { ['^/' + pro + '/pt']: `/${pro}/pt` }
94
- },
95
- ['/' + pro + '/cj']: {
96
- target: target,
97
- pathRewrite: { ['^/' + pro + '/cj']: `/${pro}/cj` }
98
- },
99
- ['/' + pro + '/api']: {
100
- target: target,
101
- pathRewrite: { ['^/' + pro + '/api']: `/${pro}/api` }
102
- },
103
- ['/' + pro + '/login']: {
104
- target: target,
105
- pathRewrite: { ['^/' + pro + '/login']: `/${pro}/login` }
106
- },
107
- ['/' + pro + '/tps']: {
108
- target: target,
109
- pathRewrite: { ['^/' + pro + '/tps']: `/${pro}/tps` }
110
- },
111
- ['/' + pro + '/tk']: {
112
- target: target,
113
- pathRewrite: { ['^/' + pro + '/tk']: `/${pro}/tk` }
114
- },
115
- ['/' + pro + '/ks']: {
116
- target: target,
117
- pathRewrite: { ['^/' + pro + '/ks']: `/${pro}/ks` }
118
- }
119
- }
120
- }
121
-
122
- module.exports = {
123
- proxy,
124
- setPackParams
125
- }
126
-
13
+ const NPM_APP_CDN_URL = 'https://pub-static.yks365.net/assets'
14
+ const NPM_APP_DEV_URL = 'https://gldev.cetset.com'
15
+ const NPM_APP_TEST_URL = 'https://gltest.cetset.com'
16
+ const NPM_APP_PRE_URL = 'https://glpre.yks365.net'
17
+ const NPM_APP_PROD_URL = 'https://gl.yks365.net'
18
+
19
+ const getConfig = () => {
20
+ let cdnConfigs = [
21
+ {
22
+ name: 'vue',
23
+ library: 'Vue',
24
+ js: `${NPM_APP_CDN_URL}/cdn/vue.min@2.6.11.js`,
25
+ dev: `${NPM_APP_CDN_URL}/cdn/vue@2.6.11.js`,
26
+ css: ''
27
+ },
28
+ {
29
+ name: 'vuex',
30
+ library: 'Vuex',
31
+ js: `${NPM_APP_CDN_URL}/cdn/vuex.min@3.3.0.js`,
32
+ css: ''
33
+ },
34
+ {
35
+ name: 'vue-router',
36
+ library: 'VueRouter',
37
+ js: `${NPM_APP_CDN_URL}/cdn/vue-router@3.5.3.js`,
38
+ css: ''
39
+ },
40
+ {
41
+ name: 'axios',
42
+ library: 'axios',
43
+ js: `${NPM_APP_CDN_URL}/cdn/axios.min@0.19.2.js`,
44
+ css: ''
45
+ },
46
+ {
47
+ name: 'yks-element',
48
+ library: 'YKSEMENT',
49
+ js: `${NPM_APP_CDN_URL}/yks-element/latest/yks.js`,
50
+ css: `${NPM_APP_CDN_URL}/yks-element/latest/theme-chalk/index.css`
51
+ },
52
+ {
53
+ name: 'lodash',
54
+ library: 'lodash',
55
+ js: `${NPM_APP_CDN_URL}/cdn/lodash.min@4.17.15.js`,
56
+ css: ''
57
+ },
58
+ {
59
+ name: 'echarts',
60
+ library: 'echarts',
61
+ js: `${NPM_APP_CDN_URL}/cdn/echarts.min@4.7.0.js`,
62
+ css: ''
63
+ }
64
+ ]
65
+ return cdnConfigs
66
+ }
67
+
68
+ const externals = () => {
69
+ let externals = {}
70
+ let cdnConfig = getConfig()
71
+ cdnConfig.forEach((pkg) => {
72
+ externals[pkg.name] = pkg.library === 'Vue' ? `${pkg.library}` : pkg.library
73
+ })
74
+ return externals
75
+ }
76
+
77
+ const cdn = (env) => {
78
+ const cdnConfig = getConfig()
79
+ const js = []
80
+ const css = []
81
+ cdnConfig.forEach((v) => {
82
+ const value = env === 'development' && v.name === 'vue' ? v.dev : v.js
83
+ js.push(value)
84
+ if (v.css && v.css !== '') css.push(v.css)
85
+ })
86
+ return {
87
+ css,
88
+ js
89
+ }
90
+ }
91
+
92
+ const setPackParams = (config, env) => {
93
+ config.plugin('html').tap((args) => {
94
+ let cdns = cdn(env)
95
+ args[0].cdn = cdns
96
+ return args
97
+ })
98
+ }
99
+
100
+ const proxy = (pro, env, targets) => {
101
+ if (!pro || !env) {
102
+ return new Error('pro or env is not difine !')
103
+ }
104
+ const params = {
105
+ dev: NPM_APP_DEV_URL,
106
+ test: NPM_APP_TEST_URL,
107
+ pre: NPM_APP_PRE_URL,
108
+ prod: NPM_APP_PROD_URL
109
+ }
110
+ const target = params[env] ? params[env] : targets
111
+ return {
112
+ ['/' + pro + '/bm']: {
113
+ target: target,
114
+ pathRewrite: { ['^/' + pro + '/bm']: `/${pro}/bm` }
115
+ },
116
+ ['/' + pro + '/pj']: {
117
+ target: target,
118
+ pathRewrite: { ['^/' + pro + '/pj']: `/${pro}/pj` }
119
+ },
120
+ ['/' + pro + '/ua']: {
121
+ target: target,
122
+ pathRewrite: { ['^/' + pro + '/ua']: `/${pro}/ua` }
123
+ },
124
+ ['/' + pro + '/gov']: {
125
+ target: target,
126
+ pathRewrite: { ['^/' + pro + '/gov']: `/${pro}/gov` }
127
+ },
128
+ ['/' + pro + '/kw']: {
129
+ target: target,
130
+ pathRewrite: { ['^/' + pro + '/kw']: `/${pro}/kw` }
131
+ },
132
+ ['/' + pro + '/pt']: {
133
+ target: target,
134
+ pathRewrite: { ['^/' + pro + '/pt']: `/${pro}/pt` }
135
+ },
136
+ ['/' + pro + '/cj']: {
137
+ target: target,
138
+ pathRewrite: { ['^/' + pro + '/cj']: `/${pro}/cj` }
139
+ },
140
+ ['/' + pro + '/api']: {
141
+ target: target,
142
+ pathRewrite: { ['^/' + pro + '/api']: `/${pro}/api` }
143
+ },
144
+ ['/' + pro + '/login']: {
145
+ target: target,
146
+ pathRewrite: { ['^/' + pro + '/login']: `/${pro}/login` }
147
+ },
148
+ ['/' + pro + '/tps']: {
149
+ target: target,
150
+ pathRewrite: { ['^/' + pro + '/tps']: `/${pro}/tps` }
151
+ },
152
+ ['/' + pro + '/tk']: {
153
+ target: target,
154
+ pathRewrite: { ['^/' + pro + '/tk']: `/${pro}/tk` }
155
+ },
156
+ ['/' + pro + '/ks']: {
157
+ target: target,
158
+ pathRewrite: { ['^/' + pro + '/ks']: `/${pro}/ks` }
159
+ }
160
+ }
161
+ }
162
+
163
+ module.exports = {
164
+ proxy,
165
+ externals,
166
+ setPackParams
167
+ }