@dcloudio/vue-cli-plugin-uni 2.0.2-4050620250310001 → 2.0.2-4050620250311001

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/env.js CHANGED
@@ -45,6 +45,23 @@ process.env.UNI_APP_VERSION_NAME = manifestJsonObj.versionName
45
45
  process.env.UNI_APP_VERSION_CODE = manifestJsonObj.versionCode
46
46
  process.env.VUE_APP_DARK_MODE = (manifestJsonObj[process.env.UNI_PLATFORM] || {}).darkmode || false
47
47
 
48
+ // 如果配置了 dart-sass 或者是 Mac Arm 版本
49
+
50
+ const {
51
+ isInHBuilderX
52
+ } = require('@dcloudio/uni-cli-shared/lib/util')
53
+ if (isInHBuilderX) {
54
+ const isMacArm = process.platform === 'darwin' && process.arch === 'arm64'
55
+ if (isMacArm && manifestJsonObj.sassImplementationName === 'node-sass') {
56
+ console.warn('HBuilderX Mac Arm 版本 manifest.json->sassImplementationName 仅支持 dart-sass')
57
+ }
58
+ if (manifestJsonObj.sassImplementationName !== 'node-sass' || isMacArm) {
59
+ process.env.UNI_SASS_IMPLEMENTATION_NAME = 'dart-sass'
60
+ moduleAlias.addAlias('sass', path.resolve(process.env.UNI_HBUILDERX_PLUGINS,
61
+ 'compile-dart-sass/node_modules/sass'))
62
+ }
63
+ }
64
+
48
65
  // 小程序 vue3 标记
49
66
  if (process.env.UNI_PLATFORM.indexOf('mp-') === 0) {
50
67
  if (manifestJsonObj.vueVersion === '3' || manifestJsonObj.vueVersion === 3) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcloudio/vue-cli-plugin-uni",
3
- "version": "2.0.2-4050620250310001",
3
+ "version": "2.0.2-4050620250311001",
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-4050620250310001",
20
+ "@dcloudio/uni-stat": "^2.0.2-4050620250311001",
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": "bf64a92aa5bc2045e260b02c6bd59d0f7a8e9816"
44
+ "gitHead": "4eb4b980d55655c7e8473afbece9261f985467c2"
45
45
  }
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
 
8
8
  function getDefaultSassImplementation() {
9
- if (process.platform === 'darwin' && process.arch === 'arm64') {
9
+ if (process.env.UNI_SASS_IMPLEMENTATION_NAME === 'dart-sass') {
10
10
  if (require('@dcloudio/uni-cli-shared').isInHBuilderX) {
11
11
  return require('sass');
12
12
  }
@@ -22,15 +22,55 @@ function formatMessage (msg) {
22
22
 
23
23
  const installPreprocessorTips = {}
24
24
 
25
- const isHBuilderXArm = process.platform === 'darwin' && process.arch === 'arm64'
25
+ const isMacArm = process.platform === 'darwin' && process.arch === 'arm64'
26
+ if (process.env.UNI_SASS_IMPLEMENTATION_NAME === 'dart-sass') {
27
+ let timeout
28
+ const originalStderrWrite = process.stderr.write
29
+ process.stderr.write = function (chunk, encoding, callback) {
30
+ if (typeof chunk === 'string' && chunk.includes('More info and automated migrator')) {
31
+ clearTimeout(timeout)
32
+ timeout = setTimeout(() => {
33
+ console.error(formatDartSassMessage(chunk))
34
+ }, 10)
35
+ }
36
+ return originalStderrWrite.apply(process.stderr, arguments)
37
+ }
38
+ }
39
+
40
+ function formatDartSassError (message) {
41
+ const msgs = []
42
+ const syntaxMsgs = []
43
+ // 识别 /deep/ 语法
44
+ if (message.includes('/deep/')) {
45
+ syntaxMsgs.push('将深度选择器 /deep/ 调整为 ::v-deep')
46
+ }
47
+ // 识别除法
48
+ if (message.includes('Using / for division is deprecated')) {
49
+ syntaxMsgs.push('将除法修改为 math.div()')
50
+ }
51
+ const address = 'https://uniapp.dcloud.net.cn/tutorial/syntax-css.html#css-preprocessor'
52
+ const syntaxMsg = syntaxMsgs.length ? `,${syntaxMsgs.join(';')}` : ''
53
+ msgs.push(
54
+ `方案1:调整为 dart-sass 支持的语法${syntaxMsg},详情:${address}`
55
+ )
56
+ msgs.push(
57
+ `方案2:如果您希望继续使用node-sass,${isMacArm ? '需要更换为 HBuilderX Mac Intel 版本,并且' : '您可以'}在 manifest.json 中配置 "sassImplementationName": "node-sass",详情:${address}`
58
+ )
59
+ return msgs.join('\n')
60
+ }
61
+
62
+ function formatDartSassMessage (message) {
63
+ const lineBreak = '\n \n'
64
+ const dartSassMsg = formatDartSassError(message)
65
+ return `${lineBreak}Vue2 sass 预编译器默认已由 node-sass 更换为 dart-sass, 可能存在部分语法不兼容的问题。
66
+ 解决方案:
67
+ ${dartSassMsg}${lineBreak}`
68
+ }
26
69
 
27
70
  function ModuleBuildError (err) {
28
- if (isHBuilderXArm) {
71
+ if (process.env.UNI_SASS_IMPLEMENTATION_NAME === 'dart-sass') {
29
72
  if (err.message.includes('SassError:')) {
30
- err.message = err.message + `\n \nHBuilderX Mac Arm 版 Vue2 sass 预编译器已由 node-sass 更换为 dart-sass,可能存在部分语法不兼容的问题(https://ask.dcloud.net.cn/question/205992)。
31
- 解决方案:
32
- 1. 调整为 dart-sass 支持的语法,比如:将深度选择器 /deep/ 调整为 ::v-deep,官方网站:https://sass-lang.com/
33
- 2. 使用 HBuilderX Mac Intel 版本,下载地址:https://www.dcloud.io/hbuilderx.html\n \n`
73
+ err.message = err.message + formatDartSassMessage(err.message)
34
74
  }
35
75
  }
36
76
  const lines = err.message.split('\n')