@dcloudio/vue-cli-plugin-uni 2.0.2-alpha-4080220250929001 → 2.0.2-alpha-4080320251016001

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/h5/index.js CHANGED
@@ -53,7 +53,8 @@ function getProvides () {
53
53
 
54
54
  const plugins = [
55
55
  new WebpackUniAppPlugin(),
56
- new webpack.ProvidePlugin(getProvides())
56
+ new webpack.ProvidePlugin(getProvides()),
57
+ new WebpackHtmlInjectAliYunPlugin(AliYunCloudAuthWebSDK)
57
58
  ]
58
59
 
59
60
  if (process.env.NODE_ENV !== 'production') {
@@ -88,12 +89,6 @@ const vueConfig = {
88
89
  }
89
90
  }
90
91
 
91
- if (process.env.NODE_ENV !== 'production') {
92
- vueConfig.pages.index.AliYunCloudAuthWebSDK = `<noscript>在运行期间注入实人认证 SDK。需要开启 JavaScript(发行期间会根据API的使用判断是否注入)</noscript>\n<script type="text/javascript" src="${AliYunCloudAuthWebSDK}"></script>`
93
- } else {
94
- plugins.push(new WebpackHtmlInjectAliYunPlugin(AliYunCloudAuthWebSDK))
95
- }
96
-
97
92
  if (devServer && Object.keys(devServer).length) {
98
93
  vueConfig.devServer = devServer
99
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.2-alpha-4080220250929001",
3
+ "version": "2.0.2-alpha-4080320251016001",
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.2-alpha-4080220250929001",
20
+ "@dcloudio/uni-stat": "^2.0.2-alpha-4080320251016001",
21
21
  "buffer-json": "^2.0.0",
22
22
  "clone-deep": "^4.0.1",
23
23
  "cross-env": "^5.2.0",
@@ -41,5 +41,5 @@
41
41
  "copy-webpack-plugin": ">=5",
42
42
  "postcss": ">=7"
43
43
  },
44
- "gitHead": "0d7e5f3448dc8fbae6009ecee36efb8e4122e23d"
44
+ "gitHead": "f86904c1ba927ee0a2062489e3e001ceb160814f"
45
45
  }
@@ -2,8 +2,6 @@ const webpack = require('webpack')
2
2
  const HtmlWebpackPlugin = require('html-webpack-plugin')
3
3
 
4
4
  class WebpackHtmlInjectAliYunPlugin {
5
- isEnableFacialRecognition = false;
6
- isInserted = false;
7
5
  AliYunCloudAuthWebSDK = '';
8
6
 
9
7
  constructor (AliYunCloudAuthWebSDK) {
@@ -13,14 +11,13 @@ class WebpackHtmlInjectAliYunPlugin {
13
11
  apply (compiler) {
14
12
  if (webpack.version[0] > 4) {
15
13
  compiler.hooks.compilation.tap('WebpackHtmlInjectAliYunPlugin', compilation => {
16
- compilation.hooks.processAssets.tap(
17
- {
18
- name: 'WebpackHtmlInjectAliYunPlugin',
19
- stage: webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING
20
- },
21
- _ => {
22
- this.analyze(compilation)
23
- }
14
+ compilation.hooks.processAssets.tap({
15
+ name: 'WebpackHtmlInjectAliYunPlugin',
16
+ stage: webpack.Compilation.PROCESS_ASSETS_STAGE_DEV_TOOLING
17
+ },
18
+ _ => {
19
+ this.analyze(compilation)
20
+ }
24
21
  )
25
22
  })
26
23
  } else {
@@ -34,49 +31,42 @@ class WebpackHtmlInjectAliYunPlugin {
34
31
  }
35
32
 
36
33
  analyze (compilation) {
37
- if (this.isInserted) {
38
- return
39
- }
40
- if (!this.isEnableFacialRecognition) {
41
- const assets = compilation.assets
42
- const chunkNames = Object.keys(assets).filter(name =>
43
- name.endsWith('.js') && !name.includes('chunk-vendors')
44
- )
45
- chunkNames.forEach(name => {
46
- if (!this.isEnableFacialRecognition) {
47
- const asset = assets[name]
48
- const source = asset.source()
49
-
50
- this.isEnableFacialRecognition = source.includes('uni.getFacialRecognitionMetaInfo')
51
- }
52
- })
53
- }
54
-
55
- if (!this.isEnableFacialRecognition) return
34
+ const assets = compilation.assets
35
+ const chunkNames = Object.keys(assets).filter(name =>
36
+ name.endsWith('.js') && !name.includes('chunk-vendors')
37
+ )
38
+ const findChunkName = chunkNames.find(name => {
39
+ const asset = assets[name]
40
+ const source = asset.source()
41
+ return source.includes('getFacialRecognitionMetaInfo') || source.includes('window.getMetaInfo')
42
+ })
43
+ if (!findChunkName) return
56
44
 
57
45
  if (compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration) {
58
46
  compilation.hooks.htmlWebpackPluginBeforeHtmlGeneration.tapAsync(
59
47
  'WebpackHtmlInjectAliYunPlugin',
60
48
  (data, cb) => {
61
- if (!this.isInserted) {
49
+ const index = data.assets.js.indexOf(this.AliYunCloudAuthWebSDK)
50
+ if (index === -1) {
62
51
  data.assets.js.unshift(this.AliYunCloudAuthWebSDK)
63
- this.isInserted = true
64
- cb(null, data)
65
52
  }
53
+ cb(null, data)
66
54
  }
67
55
  )
68
- } else if (!this.isInserted) {
56
+ } else {
69
57
  const hooks = HtmlWebpackPlugin.getHooks(compilation)
70
58
  if (hooks) {
71
59
  hooks.beforeAssetTagGeneration.tapAsync(
72
60
  'WebpackHtmlInjectAliYunPlugin',
73
61
  (data, cb) => {
74
- data.assets.js.unshift(this.AliYunCloudAuthWebSDK)
62
+ const index = data.assets.js.indexOf(this.AliYunCloudAuthWebSDK)
63
+ if (index === -1) {
64
+ data.assets.js.unshift(this.AliYunCloudAuthWebSDK)
65
+ }
75
66
  cb(null, data)
76
67
  }
77
68
  )
78
69
  }
79
- this.isInserted = true
80
70
  }
81
71
  }
82
72
  }