@dcloudio/vue-cli-plugin-hbuilderx 2.0.0 → 2.0.1-33420211227001

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.
@@ -56,14 +56,14 @@ if (isSass) {
56
56
  }
57
57
 
58
58
  const scssLoader = {
59
- loader: 'sass-loader',
59
+ loader: '@dcloudio/vue-cli-plugin-uni/packages/sass-loader',
60
60
  options: {
61
61
  sourceMap: false
62
62
  }
63
63
  }
64
64
 
65
65
  const sassLoader = {
66
- loader: 'sass-loader',
66
+ loader: '@dcloudio/vue-cli-plugin-uni/packages/sass-loader',
67
67
  options: {
68
68
  sourceMap: false
69
69
  }
@@ -11,7 +11,7 @@ const {
11
11
  nvueHtmlPreprocessOptions,
12
12
  getTemplatePath
13
13
  } = require('@dcloudio/uni-cli-shared')
14
-
14
+ const fileLoader = require('@dcloudio/uni-cli-shared/lib/file-loader')
15
15
  const WebpackAppPlusNVuePlugin = process.env.UNI_USING_V3
16
16
  ? require('../packages/webpack-app-plus-plugin')
17
17
  : require('../packages/webpack-app-plus-nvue-plugin')
@@ -79,9 +79,13 @@ const plugins = [
79
79
  new webpack.DefinePlugin({
80
80
  'process.env': {
81
81
  NODE_ENV: JSON.stringify(process.env.NODE_ENV),
82
+ UNI_APP_ID: JSON.stringify(process.env.UNI_APP_ID),
83
+ UNI_APP_NAME: JSON.stringify(process.env.UNI_APP_NAME),
84
+ UNI_PLATFORM: JSON.stringify(process.env.UNI_PLATFORM),
82
85
  VUE_APP_PLATFORM: JSON.stringify(process.env.UNI_PLATFORM),
83
86
  UNI_CLOUD_PROVIDER: process.env.UNI_CLOUD_PROVIDER,
84
- HBX_USER_TOKEN: JSON.stringify(process.env.HBX_USER_TOKEN || ''),
87
+ UNICLOUD_DEBUG: process.env.UNICLOUD_DEBUG,
88
+ RUN_BY_HBUILDERX: process.env.RUN_BY_HBUILDERX,
85
89
  UNI_AUTOMATOR_WS_ENDPOINT: JSON.stringify(process.env.UNI_AUTOMATOR_WS_ENDPOINT)
86
90
  }
87
91
  }),
@@ -105,6 +109,9 @@ if (process.env.NODE_ENV === 'development') {
105
109
  // const excludeModuleReg = /node_modules(?!(\/|\\).*(weex).*)/
106
110
 
107
111
  const rules = [{
112
+ test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/i,
113
+ use: [fileLoader]
114
+ }, {
108
115
  test: path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
109
116
  use: [{
110
117
  loader: '@dcloudio/webpack-uni-pages-loader'
@@ -179,40 +186,50 @@ rules.unshift({
179
186
  loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle'
180
187
  }]
181
188
  })
182
-
183
- if (process.env.UNI_USING_V3_NATIVE) {
184
- try {
185
- const automatorJson = require.resolve('@dcloudio/uni-automator/dist/automator.json')
186
- plugins.push(new CopyWebpackPlugin([{
187
- from: automatorJson,
188
- to: '../.automator/' + (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM) +
189
- '/.automator.json',
190
- transform (content) {
191
- if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
192
- return JSON.stringify({
193
- version: require('@dcloudio/uni-automator/package.json').version,
194
- wsEndpoint: process.env.UNI_AUTOMATOR_WS_ENDPOINT
195
- })
196
- }
197
- return ''
198
- }
199
- }]))
200
- } catch (e) {}
201
- }
189
+
190
+ if (process.env.UNI_USING_V3_NATIVE) {
191
+ try {
192
+ const automatorJson = require.resolve('@dcloudio/uni-automator/dist/automator.json')
193
+ plugins.push(new CopyWebpackPlugin([{
194
+ from: automatorJson,
195
+ to: '../.automator/' + (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM) +
196
+ '/.automator.json',
197
+ transform (content) {
198
+ if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
199
+ return JSON.stringify({
200
+ version: require('@dcloudio/uni-automator/package.json').version,
201
+ wsEndpoint: process.env.UNI_AUTOMATOR_WS_ENDPOINT
202
+ })
203
+ }
204
+ return ''
205
+ }
206
+ }]))
207
+ } catch (e) {}
208
+ }
202
209
 
203
210
  if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
204
211
  plugins.push(new WebpackUniMPPlugin())
205
212
  const array = [{
206
213
  from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
207
214
  to: 'static'
208
- }]
209
- const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
210
- if (fs.existsSync(hybridHtmlPath)) {
211
- array.push({
212
- from: hybridHtmlPath,
213
- to: 'hybrid/html'
214
- })
215
+ }]
216
+
217
+ const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
218
+ if (fs.existsSync(androidPrivacyPath)) {
219
+ array.push({
220
+ from: androidPrivacyPath,
221
+ to: 'androidPrivacy.json'
222
+ })
223
+ }
224
+
225
+ const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
226
+ if (fs.existsSync(hybridHtmlPath)) {
227
+ array.push({
228
+ from: hybridHtmlPath,
229
+ to: 'hybrid/html'
230
+ })
215
231
  }
232
+
216
233
  if (process.env.UNI_USING_NVUE_COMPILER) {
217
234
  array.push({
218
235
  from: path.resolve(getTemplatePath(), 'common'),
@@ -251,6 +268,18 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
251
268
  plugins.push(new CopyWebpackPlugin(array))
252
269
  }
253
270
 
271
+ try {
272
+ if (process.env.UNI_HBUILDERX_PLUGINS) {
273
+ require(path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers/lib/bytenode'))
274
+ const {
275
+ W
276
+ } = require(path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'uni_helpers'))
277
+ plugins.push(new W({
278
+ dir: process.env.UNI_INPUT_DIR
279
+ }))
280
+ }
281
+ } catch (e) {}
282
+
254
283
  module.exports = function () {
255
284
  return {
256
285
  target: 'node', // 激活 vue-loader 的 isServer 逻辑
@@ -360,4 +389,4 @@ module.exports = function () {
360
389
  zlib: false
361
390
  }
362
391
  }
363
- }
392
+ }
package/index.js CHANGED
@@ -1,7 +1,8 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const uniI18n = require('@dcloudio/uni-cli-i18n')
3
4
 
4
- process.env.UNI_CLI_CONTEXT = path.resolve(__dirname, '../../../')
5
+ process.env.UNI_CLI_CONTEXT = require('@dcloudio/uni-cli-shared/lib/util').getCLIContext()
5
6
 
6
7
  process.env.UNI_HBUILDERX_PLUGINS = process.env.UNI_HBUILDERX_PLUGINS || path.resolve(__dirname, '../../../../')
7
8
 
@@ -18,7 +19,7 @@ module.exports = (api, options) => { // 仅处理 app-plus 相关逻辑
18
19
  !process.env.UNI_USING_V3_NATIVE
19
20
  ) {
20
21
  if (!fs.existsSync(path.resolve(process.env.UNI_HBUILDERX_PLUGINS, 'weapp-tools/lib/index.js'))) {
21
- console.error('请使用 HBuilderX 编译运行至 app-plus 平台')
22
+ console.error(uniI18n.__('pluginHbuilderx.plaseHXCompileAppPlatform'))
22
23
  process.exit(0)
23
24
  }
24
25
  }
@@ -36,4 +37,4 @@ module.exports = (api, options) => { // 仅处理 app-plus 相关逻辑
36
37
  plugins
37
38
  }
38
39
  })
39
- }
40
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-hbuilderx",
3
- "version": "2.0.0",
3
+ "version": "2.0.1-33420211227001",
4
4
  "description": "HBuilderX plugin for vue-cli 3",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -18,5 +18,5 @@
18
18
  "css": "~2.2.1",
19
19
  "escodegen": "^1.8.1"
20
20
  },
21
- "gitHead": "b1bdfb4de3f518c1c0fbab242403ea05feced4e3"
21
+ "gitHead": "f54af18016d88ecbd0776ad013f5c1eb65a8debe"
22
22
  }
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const uniI18n = require('@dcloudio/uni-cli-i18n')
3
4
 
4
5
  const {
5
6
  log,
@@ -19,7 +20,7 @@ let isFirst = true
19
20
  let compiling = false
20
21
  class WebpackAppPlusPlugin {
21
22
  apply (compiler) {
22
- if (process.env.UNI_USING_V3) {
23
+ if (process.env.UNI_USING_V3) {
23
24
  const chunkVersions = {}
24
25
 
25
26
  const entry = compiler.options.entry()
@@ -31,7 +32,7 @@ class WebpackAppPlusPlugin {
31
32
  compiler.hooks.invalid.tap('WebpackAppPlusPlugin', (fileName, changeTime) => {
32
33
  if (!compiling) {
33
34
  compiling = true
34
- console.log('开始差量编译...')
35
+ console.log(uniI18n.__('performingHotReload'))
35
36
  }
36
37
  })
37
38
 
@@ -100,7 +101,7 @@ class WebpackAppPlusPlugin {
100
101
  })
101
102
  } else {
102
103
  compiler.hooks.done.tapPromise('WebpackAppPlusPlugin', compilation => {
103
- return new Promise((resolve, reject) => {
104
+ return new Promise((resolve, reject) => {
104
105
  if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
105
106
  return resolve()
106
107
  }
@@ -137,4 +138,4 @@ class WebpackAppPlusPlugin {
137
138
  }
138
139
  }
139
140
 
140
- module.exports = WebpackAppPlusPlugin
141
+ module.exports = WebpackAppPlusPlugin
@@ -7,6 +7,8 @@ module.exports = function (content, map) {
7
7
  this.cacheable && this.cacheable()
8
8
  this.callback(null, 'module.exports = ' + genStyleString(content, this), map)
9
9
  }
10
+ const uniI18n = require('@dcloudio/uni-cli-i18n')
11
+ const print = require('../../../util/console')
10
12
 
11
13
  // @todo:
12
14
  // font-relative lengths: em, ex, ch, ic
@@ -52,12 +54,22 @@ function genStyleString (input, loader) {
52
54
  })
53
55
  if (msgs.length) {
54
56
  if (isFirst) {
55
- msgs.unshift(
56
- 'nvue中不支持如下css。如全局或公共样式受影响,建议将告警样式写在ifndef APP-PLUS-NVUE的条件编译中,详情如下:'
57
- )
57
+ msgs.unshift(uniI18n.__('pluginHbuilderx.nvueCssWarning'))
58
58
  isFirst = false
59
59
  }
60
- msgs.forEach(msg => console.warn(msg))
60
+ msgs.forEach(msg => {
61
+ switch (msg.split(':')[0]) {
62
+ case 'ERROR':
63
+ print.error(msg)
64
+ break
65
+ case 'WARNING' :
66
+ print.warn(msg)
67
+ break
68
+ default:
69
+ print.log(msg)
70
+ break
71
+ }
72
+ })
61
73
  }
62
74
  }
63
75
  try {
@@ -549,6 +549,7 @@ function FLEW_WRAP_VALIDATOR (v) {
549
549
 
550
550
  var PROP_NAME_GROUPS = {
551
551
  boxModel: {
552
+ display: genEnumValidator(['flex']),
552
553
  width: LENGTH_VALIDATOR,
553
554
  height: LENGTH_VALIDATOR,
554
555
  overflow: genEnumValidator(['hidden']),
@@ -1,9 +1,10 @@
1
1
  #!/usr/bin/env node
2
+ const uniI18n = require('@dcloudio/uni-cli-i18n')
2
3
 
3
4
  // TODO 暂时处理安装目录包含特殊符号,导致 H5 预览资源加载失败的问题。
4
5
  const matchSymbol = __dirname.match(/[()]/)
5
6
  if (matchSymbol) {
6
- console.error(`编译失败:HBuilderX 安装目录不能包括 ${matchSymbol[0]} 等特殊字符`)
7
+ console.error(uniI18n.__('pluginHbuilderx.hxBuildFailed', { "0": matchSymbol[0] }))
7
8
  process.exit(0)
8
9
  }
9
10
 
@@ -22,10 +23,10 @@ process.env.UNI_OUTPUT_DIR = path.resolve(process.env.UNI_OUTPUT_DIR)
22
23
  const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
23
24
 
24
25
  service.run((process.env.NODE_ENV === 'development' && process.env.UNI_PLATFORM === 'h5') ? 'uni-serve' : 'uni-build', {
25
- watch: process.env.NODE_ENV === 'development',
26
+ watch: process.env.NODE_ENV === 'development',
26
27
  minimize: process.env.UNI_MINIMIZE === 'true',
27
28
  clean: false
28
29
  }).catch(err => {
29
30
  error(err)
30
31
  process.exit(1)
31
- })
32
+ })
@@ -0,0 +1,23 @@
1
+ const ZERO_WIDTH_CHAR = {
2
+ NOTE: '',
3
+ WARNING: '\u200B',
4
+ ERROR: '\u200C',
5
+ backup0: '\u200D',
6
+ backup1: '\u200E',
7
+ backup2: '\u200F',
8
+ backup3: '\uFEFF'
9
+ }
10
+
11
+ module.exports = {
12
+ warn (msg) {
13
+ msg = ZERO_WIDTH_CHAR.WARNING + msg + ZERO_WIDTH_CHAR.WARNING
14
+ console.warn(msg)
15
+ },
16
+ error (msg) {
17
+ msg = ZERO_WIDTH_CHAR.ERROR + msg + ZERO_WIDTH_CHAR.ERROR
18
+ console.error(msg)
19
+ },
20
+ log (msg) {
21
+ console.log(msg)
22
+ }
23
+ }