@dcloudio/vue-cli-plugin-hbuilderx 2.0.1-alpha-35420220804001 → 2.0.1-alpha-35420220810001

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.
@@ -1,5 +1,6 @@
1
1
  const fs = require('fs')
2
2
  const path = require('path')
3
+ const webpack = require('webpack')
3
4
 
4
5
  const {
5
6
  getPlatformScss,
@@ -7,10 +8,6 @@ const {
7
8
  nvueCssPreprocessOptions
8
9
  } = require('@dcloudio/uni-cli-shared')
9
10
 
10
- const {
11
- sassLoaderVersion
12
- } = require('@dcloudio/uni-cli-shared/lib/scss')
13
-
14
11
  const nvueStyleLoader = {
15
12
  loader: '@dcloudio/vue-cli-plugin-hbuilderx/packages/webpack-uni-nvue-loader/lib/style'
16
13
  }
@@ -20,27 +17,33 @@ const preprocessLoader = {
20
17
  options: nvueCssPreprocessOptions
21
18
  }
22
19
 
20
+ const options = {
21
+ sourceMap: false
22
+ }
23
+ const plugins = [
24
+ require('postcss-import')({
25
+ resolve (id, basedir, importOptions) {
26
+ if (id.startsWith('~@/')) {
27
+ return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
28
+ } else if (id.startsWith('@/')) {
29
+ return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
30
+ } else if (id.startsWith('/') && !id.startsWith('//')) {
31
+ return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
32
+ }
33
+ return id
34
+ }
35
+ }),
36
+ require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
37
+ ]
38
+ if (webpack.version[0] > 4) {
39
+ options.postcssOptions = { plugins }
40
+ } else {
41
+ options.parser = require('postcss-comment')
42
+ options.plugins = plugins
43
+ }
23
44
  const postcssLoader = {
24
45
  loader: 'postcss-loader',
25
- options: {
26
- sourceMap: false,
27
- parser: require('postcss-comment'),
28
- plugins: [
29
- require('postcss-import')({
30
- resolve (id, basedir, importOptions) {
31
- if (id.startsWith('~@/')) {
32
- return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
33
- } else if (id.startsWith('@/')) {
34
- return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
35
- } else if (id.startsWith('/') && !id.startsWith('//')) {
36
- return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
37
- }
38
- return id
39
- }
40
- }),
41
- require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
42
- ]
43
- }
46
+ options
44
47
  }
45
48
 
46
49
  // sass 全局变量
@@ -71,25 +74,15 @@ const sassLoader = {
71
74
  }
72
75
  }
73
76
 
74
- if (sassLoaderVersion < 8) {
75
- scssLoader.options.data = sassData
76
- scssLoader.options.outputStyle = 'expanded'
77
-
78
- sassLoader.options.data = sassData
79
- sassLoader.options.outputStyle = 'expanded'
80
- sassLoader.options.indentedSyntax = true
81
- } else {
82
- const name = sassLoaderVersion >= 9 ? 'additionalData' : 'prependData'
83
- scssLoader.options[name] = sassData
84
- scssLoader.options.sassOptions = {
85
- outputStyle: 'expanded'
86
- }
77
+ scssLoader.options.prependData = sassData
78
+ scssLoader.options.sassOptions = {
79
+ outputStyle: 'expanded'
80
+ }
87
81
 
88
- sassLoader.options[name] = sassData
89
- sassLoader.options.sassOptions = {
90
- outputStyle: 'expanded',
91
- indentedSyntax: true
92
- }
82
+ sassLoader.options.prependData = sassData
83
+ sassLoader.options.sassOptions = {
84
+ outputStyle: 'expanded',
85
+ indentedSyntax: true
93
86
  }
94
87
 
95
88
  const lessLoader = {
@@ -143,4 +136,4 @@ module.exports = [{
143
136
  }, {
144
137
  test: /\.styl(us)?$/,
145
138
  oneOf: createOneOf(stylusLoader)
146
- }]
139
+ }]
@@ -3,6 +3,7 @@ const path = require('path')
3
3
  const webpack = require('webpack')
4
4
  const VueLoaderPlugin = require('@dcloudio/vue-cli-plugin-uni/packages/vue-loader/lib/plugin')
5
5
  const CopyWebpackPlugin = require('copy-webpack-plugin')
6
+ const CopyWebpackPluginVersion = Number(require('copy-webpack-plugin/package.json').version.split('.')[0])
6
7
  const TerserPlugin = require('terser-webpack-plugin')
7
8
 
8
9
  const {
@@ -112,7 +113,10 @@ if (process.env.NODE_ENV === 'development') {
112
113
 
113
114
  // const excludeModuleReg = /node_modules(?!(\/|\\).*(weex).*)/
114
115
 
115
- const rules = [{
116
+ const rules = [webpack.version[0] > 4 ? {
117
+ test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i,
118
+ type: 'asset'
119
+ } : {
116
120
  test: /\.(png|jpg|gif|ttf|eot|woff|woff2)$/i,
117
121
  use: [fileLoader]
118
122
  }, {
@@ -194,7 +198,7 @@ rules.unshift({
194
198
  if (process.env.UNI_USING_V3_NATIVE) {
195
199
  try {
196
200
  const automatorJson = require.resolve('@dcloudio/uni-automator/dist/automator.json')
197
- plugins.push(new CopyWebpackPlugin([{
201
+ const patterns = [{
198
202
  from: automatorJson,
199
203
  to: '../.automator/' + (process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM) +
200
204
  '/.automator.json',
@@ -207,15 +211,16 @@ if (process.env.UNI_USING_V3_NATIVE) {
207
211
  }
208
212
  return ''
209
213
  }
210
- }]))
211
- } catch (e) {}
214
+ }]
215
+ plugins.push(new CopyWebpackPlugin(CopyWebpackPluginVersion > 5 ? { patterns } : patterns))
216
+ } catch (e) { }
212
217
  }
213
218
 
214
219
  if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
215
220
  plugins.push(new WebpackUniMPPlugin())
216
221
  const assetsDir = 'static'
217
222
  const hybridDir = 'hybrid/html'
218
- const array = [{
223
+ const patterns = [{
219
224
  from: path.resolve(process.env.UNI_INPUT_DIR, assetsDir),
220
225
  to: assetsDir
221
226
  }]
@@ -223,7 +228,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
223
228
  if (!process.env.UNI_AUTOMATOR_WS_ENDPOINT) {
224
229
  const androidPrivacyPath = path.resolve(process.env.UNI_INPUT_DIR, 'androidPrivacy.json')
225
230
  if (fs.existsSync(androidPrivacyPath)) {
226
- array.push({
231
+ patterns.push({
227
232
  from: androidPrivacyPath,
228
233
  to: 'androidPrivacy.json'
229
234
  })
@@ -231,7 +236,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
231
236
  }
232
237
  const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, hybridDir)
233
238
  if (fs.existsSync(hybridHtmlPath)) {
234
- array.push({
239
+ patterns.push({
235
240
  from: hybridHtmlPath,
236
241
  to: hybridDir
237
242
  })
@@ -242,7 +247,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
242
247
  const assets = modules + module + '/' + assetsDir
243
248
  const assetsPath = path.resolve(process.env.UNI_INPUT_DIR, assets)
244
249
  if (fs.existsSync(assetsPath)) {
245
- array.push({
250
+ patterns.push({
246
251
  from: assetsPath,
247
252
  to: assets
248
253
  })
@@ -250,7 +255,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
250
255
  const hybridHtml = modules + module + '/' + hybridDir
251
256
  const hybridHtmlPath = path.resolve(process.env.UNI_INPUT_DIR, hybridHtml)
252
257
  if (fs.existsSync(hybridHtmlPath)) {
253
- array.push({
258
+ patterns.push({
254
259
  from: hybridHtmlPath,
255
260
  to: hybridHtml
256
261
  })
@@ -258,12 +263,12 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
258
263
  })
259
264
 
260
265
  if (process.env.UNI_USING_NVUE_COMPILER) {
261
- array.push({
266
+ patterns.push({
262
267
  from: path.resolve(getTemplatePath(), 'common'),
263
268
  to: process.env.UNI_OUTPUT_DIR
264
269
  })
265
270
  } else if (process.env.UNI_USING_V3_NATIVE) {
266
- array.push({
271
+ patterns.push({
267
272
  from: path.resolve(getTemplatePath(), 'weex'),
268
273
  to: process.env.UNI_OUTPUT_DIR
269
274
  })
@@ -275,7 +280,7 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
275
280
  'weapp-tools/template/v8'
276
281
  )
277
282
  }
278
- array.push({
283
+ patterns.push({
279
284
  from: nativeTemplatePath,
280
285
  to: process.env.UNI_OUTPUT_DIR
281
286
  }, {
@@ -284,15 +289,17 @@ if (process.env.UNI_USING_NATIVE || process.env.UNI_USING_V3_NATIVE) {
284
289
  'weapp-tools/template/common'
285
290
  ),
286
291
  to: process.env.UNI_OUTPUT_DIR,
287
- ignore: [
288
- '*.js',
289
- '*.json',
290
- '__uniapppicker.html',
291
- '__uniappview.html'
292
- ]
292
+ globOptions: {
293
+ ignore: [
294
+ '*.js',
295
+ '*.json',
296
+ '__uniapppicker.html',
297
+ '__uniappview.html'
298
+ ]
299
+ }
293
300
  })
294
301
  }
295
- plugins.push(new CopyWebpackPlugin(array))
302
+ plugins.push(new CopyWebpackPlugin(CopyWebpackPluginVersion > 5 ? { patterns } : patterns))
296
303
  }
297
304
 
298
305
  try {
@@ -305,7 +312,7 @@ try {
305
312
  dir: process.env.UNI_INPUT_DIR
306
313
  }))
307
314
  }
308
- } catch (e) {}
315
+ } catch (e) { }
309
316
 
310
317
  module.exports = function () {
311
318
  return {
@@ -322,8 +329,7 @@ module.exports = function () {
322
329
  performance: {
323
330
  hints: false
324
331
  },
325
- optimization: {
326
- namedModules: false,
332
+ optimization: Object.assign({
327
333
  minimizer: [
328
334
  new TerserPlugin({
329
335
  terserOptions: {
@@ -333,7 +339,7 @@ module.exports = function () {
333
339
  }
334
340
  })
335
341
  ]
336
- },
342
+ }, webpack.version[0] > 4 ? {} : { namedModules: false }),
337
343
  output: {
338
344
  path: process.env.UNI_OUTPUT_DIR,
339
345
  filename: '[name].js'
@@ -377,7 +383,7 @@ module.exports = function () {
377
383
  reasons: true,
378
384
  errorDetails: true
379
385
  },
380
- node: {
386
+ node: webpack.version[0] > 4 ? false : {
381
387
  global: false,
382
388
  Buffer: false,
383
389
  __filename: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-hbuilderx",
3
- "version": "2.0.1-alpha-35420220804001",
3
+ "version": "2.0.1-alpha-35420220810001",
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": "84eed6604bcb83ceb45d0414ce9776acbe25e8bd"
21
+ "gitHead": "6755694c6b183543bf706e53966e795fee92946f"
22
22
  }
@@ -14,13 +14,10 @@ class WebpackAppPlusNVuePlugin {
14
14
  const changedFiles = []
15
15
  compiler.hooks.emit.tapAsync('webpack-uni-nvue', (compilation, callback) => {
16
16
  changedFiles.length = 0
17
- const changedChunks = compilation.chunks.filter(chunk => {
17
+ compilation.chunks.forEach(chunk => {
18
18
  const oldVersion = chunkVersions[chunk.name]
19
19
  chunkVersions[chunk.name] = chunk.hash
20
- return chunk.hash !== oldVersion
21
- })
22
- changedChunks.map(chunk => {
23
- if (Array.isArray(chunk.files)) {
20
+ if (chunk.hash !== oldVersion && Array.isArray(chunk.files)) {
24
21
  chunk.files.forEach(file => {
25
22
  !changedFiles.includes(file) && (changedFiles.push(file))
26
23
  })
@@ -44,13 +44,10 @@ class WebpackAppPlusPlugin {
44
44
  })
45
45
 
46
46
  compiler.hooks.emit.tapAsync('WebpackAppPlusPlugin', (compilation, callback) => {
47
- const changedChunks = compilation.chunks.filter(chunk => {
47
+ compilation.chunks.forEach(chunk => {
48
48
  const oldVersion = chunkVersions[chunk.name]
49
49
  chunkVersions[chunk.name] = chunk.hash
50
- return chunk.hash !== oldVersion
51
- })
52
- changedChunks.map(chunk => {
53
- if (Array.isArray(chunk.files)) {
50
+ if (chunk.hash !== oldVersion && Array.isArray(chunk.files)) {
54
51
  chunk.files.forEach(file => {
55
52
  if (isAppService) {
56
53
  !serviceChangedFiles.includes(file) && (serviceChangedFiles.push(file))