@dcloudio/vue-cli-plugin-uni 2.0.0-alpha-32920211101001 → 2.0.0-alpha-32920211104001
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/lib/check-update.js +56 -0
- package/lib/configure-webpack.js +19 -4
- package/lib/env.js +4 -4
- package/package.json +3 -3
package/lib/check-update.js
CHANGED
|
@@ -13,6 +13,9 @@ class Upate {
|
|
|
13
13
|
this._isAlpha = false
|
|
14
14
|
this._uniId = ''
|
|
15
15
|
this._appId = ''
|
|
16
|
+
this._wt = 0
|
|
17
|
+
this._lc = ''
|
|
18
|
+
this._lcin = []
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
get uniId () {
|
|
@@ -47,6 +50,30 @@ class Upate {
|
|
|
47
50
|
this._isAlpha = value
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
get wt () {
|
|
54
|
+
return this._wt
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
set wt (value) {
|
|
58
|
+
this._wt = value
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get lc () {
|
|
62
|
+
return this._lc
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set lc (value) {
|
|
66
|
+
this._lc = value
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get lcin () {
|
|
70
|
+
return this._lcin
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set lcin (value) {
|
|
74
|
+
this._lcin = value
|
|
75
|
+
}
|
|
76
|
+
|
|
50
77
|
get versionType () {
|
|
51
78
|
return (this.isAlpha ? 'a' : 'r')
|
|
52
79
|
}
|
|
@@ -156,6 +183,9 @@ class Upate {
|
|
|
156
183
|
data.appid = this.uniId
|
|
157
184
|
data.vtype = this.versionType
|
|
158
185
|
data.vcode = this.compilerVersion
|
|
186
|
+
data.wt = this._wt
|
|
187
|
+
data.lc = this._lc
|
|
188
|
+
data.in = this._lcin
|
|
159
189
|
|
|
160
190
|
delete data.lastCheck
|
|
161
191
|
|
|
@@ -234,6 +264,28 @@ Object.assign(Upate.prototype, {
|
|
|
234
264
|
DEFAULT_INTERVAL: 1000 * 60 * 60 * 24
|
|
235
265
|
})
|
|
236
266
|
|
|
267
|
+
function getLc () {
|
|
268
|
+
const result = []
|
|
269
|
+
const localeDir = path.join(process.env.UNI_CLI_CONTEXT, 'src/locale')
|
|
270
|
+
if (!fs.existsSync(localeDir)) {
|
|
271
|
+
return result
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const files = fs.readdirSync(localeDir)
|
|
275
|
+
for (let i = files.length - 1; i >= 0; i--) {
|
|
276
|
+
const filePath = files[i]
|
|
277
|
+
const extName = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase()
|
|
278
|
+
if (extName !== 'json') {
|
|
279
|
+
continue
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (files[i].indexOf('uni-app.') < 0) {
|
|
283
|
+
result.push(filePath.substring(0, filePath.lastIndexOf('.')))
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return result
|
|
287
|
+
}
|
|
288
|
+
|
|
237
289
|
module.exports = async function checkUpdate () {
|
|
238
290
|
const {
|
|
239
291
|
isInHBuilderX,
|
|
@@ -255,6 +307,10 @@ module.exports = async function checkUpdate () {
|
|
|
255
307
|
update.uniId = manifest.appid
|
|
256
308
|
const appIdKey = process.env.UNI_PLATFORM.includes('quickapp') ? 'package' : 'appid'
|
|
257
309
|
update.appId = manifest[process.env.UNI_PLATFORM] ? (manifest[process.env.UNI_PLATFORM][appIdKey] || '') : ''
|
|
310
|
+
const cf = manifest['mp-weixin'] ? manifest['mp-weixin'].cloudfunctionRoot : ''
|
|
311
|
+
update.wt = (cf && cf.length) ? 1 : 0
|
|
312
|
+
update.lc = manifest.locale ? manifest.locale : ''
|
|
313
|
+
update.lcin = getLc().join(',')
|
|
258
314
|
update.check()
|
|
259
315
|
} catch (e) {
|
|
260
316
|
}
|
package/lib/configure-webpack.js
CHANGED
|
@@ -15,7 +15,7 @@ function resolve (dir) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function resolveModule (dir) {
|
|
18
|
-
return path.resolve(
|
|
18
|
+
return path.resolve(process.env.UNI_CLI_CONTEXT, './node_modules', dir)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
module.exports = function configureWebpack (platformOptions, manifestPlatformOptions, vueOptions, api) {
|
|
@@ -184,8 +184,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
184
184
|
platformWebpackConfig = platformWebpackConfig(webpackConfig, vueOptions, api)
|
|
185
185
|
}
|
|
186
186
|
// 移除 node_modules 目录,避免受路径上的 node_modules 影响
|
|
187
|
-
|
|
188
|
-
'node_modules')
|
|
187
|
+
if (require('@dcloudio/uni-cli-shared/lib/util').isInHBuilderX) {
|
|
188
|
+
webpackConfig.resolve.modules = webpackConfig.resolve.modules.filter(module => module !== 'node_modules')
|
|
189
|
+
}
|
|
189
190
|
|
|
190
191
|
const plugins = []
|
|
191
192
|
|
|
@@ -298,6 +299,17 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
298
299
|
}
|
|
299
300
|
} catch (e) {}
|
|
300
301
|
|
|
302
|
+
const resolveLoaderAlias = {}
|
|
303
|
+
const modules = ['@vue/cli-plugin-babel', '@vue/cli-service']
|
|
304
|
+
modules.forEach(m => {
|
|
305
|
+
const { dependencies } = require(`${m}/package.json`)
|
|
306
|
+
Object.keys(dependencies).forEach(key => {
|
|
307
|
+
if (/-loader$/.test(key)) {
|
|
308
|
+
resolveLoaderAlias[key] = require.resolve(key)
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
|
|
301
313
|
return merge({
|
|
302
314
|
devtool: false,
|
|
303
315
|
resolve: {
|
|
@@ -325,6 +337,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
325
337
|
noParse: /^(vue|vue-router|vuex|vuex-router-sync)$/,
|
|
326
338
|
rules
|
|
327
339
|
},
|
|
340
|
+
resolveLoader: {
|
|
341
|
+
alias: resolveLoaderAlias
|
|
342
|
+
},
|
|
328
343
|
plugins,
|
|
329
344
|
performance: {
|
|
330
345
|
assetFilter (assetFilename) {
|
|
@@ -334,4 +349,4 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
334
349
|
watchOptions: require('./util').getWatchOptions()
|
|
335
350
|
}, platformWebpackConfig)
|
|
336
351
|
}
|
|
337
|
-
}
|
|
352
|
+
}
|
package/lib/env.js
CHANGED
|
@@ -107,11 +107,13 @@ if (process.env.UNI_CLOUD_SPACES) {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
// 初始化环境变量
|
|
110
|
-
|
|
110
|
+
process.env.UNI_CLI_CONTEXT = require('@dcloudio/uni-cli-shared/lib/util').getCLIContext()
|
|
111
|
+
|
|
112
|
+
const defaultOutputDir = './dist/' +
|
|
111
113
|
(process.env.NODE_ENV === 'production' ? 'build' : 'dev') + '/' +
|
|
112
114
|
(process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM)
|
|
113
115
|
|
|
114
|
-
process.env.UNI_OUTPUT_DEFAULT_DIR = path.resolve(
|
|
116
|
+
process.env.UNI_OUTPUT_DEFAULT_DIR = path.resolve(process.env.UNI_CLI_CONTEXT, defaultOutputDir)
|
|
115
117
|
if (process.env.UNI_OUTPUT_DIR && process.env.UNI_OUTPUT_DIR.indexOf('./') === 0) {
|
|
116
118
|
process.env.UNI_OUTPUT_DIR = path.resolve(process.cwd(), process.env.UNI_OUTPUT_DIR)
|
|
117
119
|
}
|
|
@@ -124,8 +126,6 @@ if (process.env.UNI_PLATFORM === 'app-plus') {
|
|
|
124
126
|
process.env.UNI_OUTPUT_TMP_DIR = path.resolve(process.env.UNI_OUTPUT_DIR, '../.tmp/app-plus')
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
process.env.UNI_CLI_CONTEXT = path.resolve(__dirname, '../../../../')
|
|
128
|
-
|
|
129
129
|
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
|
|
130
130
|
|
|
131
131
|
if (process.env.NODE_ENV === 'production') { // 发行模式,不启用 cache
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/vue-cli-plugin-uni",
|
|
3
|
-
"version": "2.0.0-alpha-
|
|
3
|
+
"version": "2.0.0-alpha-32920211104001",
|
|
4
4
|
"description": "uni-app plugin for vue-cli 3",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "fxy060608",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dcloudio/uni-stat": "^2.0.0-alpha-
|
|
20
|
+
"@dcloudio/uni-stat": "^2.0.0-alpha-32920211104001",
|
|
21
21
|
"buffer-json": "^2.0.0",
|
|
22
22
|
"copy-webpack-plugin": "^5.1.1",
|
|
23
23
|
"cross-env": "^5.2.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"wrap-loader": "^0.2.0",
|
|
38
38
|
"xregexp": "4.0.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "05e8e781d7e2ca74b140e97e5cb5884be07d6d04"
|
|
41
41
|
}
|