@dcloudio/vue-cli-plugin-hbuilderx 2.0.0 → 2.0.1-alpha-32920211110001

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.
@@ -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,6 +79,9 @@ 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
87
  HBX_USER_TOKEN: JSON.stringify(process.env.HBX_USER_TOKEN || ''),
@@ -105,6 +108,9 @@ if (process.env.NODE_ENV === 'development') {
105
108
  // const excludeModuleReg = /node_modules(?!(\/|\\).*(weex).*)/
106
109
 
107
110
  const rules = [{
111
+ test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/i,
112
+ use: [fileLoader]
113
+ }, {
108
114
  test: path.resolve(process.env.UNI_INPUT_DIR, 'pages.json'),
109
115
  use: [{
110
116
  loader: '@dcloudio/webpack-uni-pages-loader'
@@ -179,40 +185,50 @@ rules.unshift({
179
185
  loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/template.recycle'
180
186
  }]
181
187
  })
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
- }
188
+
189
+ if (process.env.UNI_USING_V3_NATIVE) {
190
+ try {
191
+ const automatorJson = require.resolve('@dcloudio/uni-automator/dist/automator.json')
192
+ plugins.push(new CopyWebpackPlugin([{
193
+ from: automatorJson,
194
+ to: '../.automator/' + (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM) +
195
+ '/.automator.json',
196
+ transform (content) {
197
+ if (process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
198
+ return JSON.stringify({
199
+ version: require('@dcloudio/uni-automator/package.json').version,
200
+ wsEndpoint: process.env.UNI_AUTOMATOR_WS_ENDPOINT
201
+ })
202
+ }
203
+ return ''
204
+ }
205
+ }]))
206
+ } catch (e) {}
207
+ }
202
208
 
203
209
  if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
204
210
  plugins.push(new WebpackUniMPPlugin())
205
211
  const array = [{
206
212
  from: path.resolve(process.env.UNI_INPUT_DIR, 'static'),
207
213
  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
- })
214
+ }]
215
+
216
+ const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
217
+ if (fs.existsSync(androidPrivacyPath)) {
218
+ array.push({
219
+ from: androidPrivacyPath,
220
+ to: 'androidPrivacy.json'
221
+ })
222
+ }
223
+
224
+ const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, 'hybrid/html')
225
+ if (fs.existsSync(hybridHtmlPath)) {
226
+ array.push({
227
+ from: hybridHtmlPath,
228
+ to: 'hybrid/html'
229
+ })
215
230
  }
231
+
216
232
  if (process.env.UNI_USING_NVUE_COMPILER) {
217
233
  array.push({
218
234
  from: path.resolve(getTemplatePath(), 'common'),
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-alpha-32920211110001",
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": "7cba94e25eba256f3cab0f2b2b73383bd25abe49"
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
+ }