Angular 9 / Nativescript 6代码共享应用未针对移动设备构建-怀疑存在SASS问题:

问题描述 投票:0回答:1

我有一个Angular 8,Nativescript 5代码共享应用程序,我将其更新为Angular 9和Nativescript6。它可以在浏览器上以及作为Electron打包的桌面应用程序使用,但无法在移动设备上构建。

构建日志的结尾显示:

CONSOLE ERROR file: node_modules/@nativescript/core/trace/trace.js:174:0: Error: Could not load CSS from app.css: ReferenceError: Can't find variable: undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedu<…>

package.json

{
  "name": "project",
  "nativescript": {
    "id": "org.nativescript.project",
    "tns-android": {
      "version": "6.5.1"
    },
    "tns-ios": {
      "version": "6.5.1"
    }
  },
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "android": "tns run android",
    "ios": "tns run ios",
    "mobile": "tns run",
    "preview": "tns preview",
    "postinstall": "ngcc",
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "9.1.9",
    "@angular/common": "9.1.9",
    "@angular/compiler": "9.1.9",
    "@angular/core": "9.1.9",
    "@angular/forms": "9.1.9",
    "@angular/localize": "^9.1.9",
    "@angular/platform-browser": "9.1.9",
    "@angular/platform-browser-dynamic": "9.1.9",
    "@angular/router": "9.1.9",
    "@nativescript/angular": "^9.0.0",
    "@nativescript/theme": "^2.3.3",
    "@ng-bootstrap/ng-bootstrap": "^6.1.0",
    "big.js": "^5.2.2",
    "bootstrap": "^4.5.0",
    "core-js": "^3.6.5",
    "reflect-metadata": "^0.1.13",
    "rxjs": "^6.4.0",
    "tslib": "^1.13.0",
    "zone.js": "^0.10.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.7",
    "@angular/cli": "^9.1.7",
    "@angular/compiler-cli": "9.1.9",
    "@nativescript/core": "^6.5.4",
    "@nativescript/schematics": "~1.0.0",
    "@nativescript/tslint-rules": "0.0.5",
    "@types/big.js": "^4.0.5",
    "@types/electron": "^1.6.10",
    "@types/jasmine": "^3.5.10",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^14.0.11",
    "codelyzer": "^5.2.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~5.0.2",
    "karma": "^5.0.9",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~3.0.3",
    "karma-jasmine": "~3.3.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "nativescript": "^6.7.4",
    "nativescript-dev-webpack": "^1.5.1",
    "node-sass": "^4.14.1",
    "nodemon": "^2.0.4",
    "protractor": "~7.0.0",
    "ts-node": "~8.10.2",
    "tslint": "~6.1.2",
    "typescript": "^3.8.3"
  }
}

app.scss文件:

@import '~@nativescript/theme/scss/variables';
@import '~@nativescript/theme/scss/variables/blue';

@import "~@nativescript/theme/core";
@import "~@nativescript/theme/blue";

webpack.config.js的摘录

{
                    test: /[\/|\\]app\.scss$/,
                    use: [
                        "nativescript-dev-webpack/style-hot-loader",
                        {
                            loader: "nativescript-dev-webpack/css2json-loader",
                            options: { useForImports: true }
                        },
                        "sass-loader"
                    ]
                },

                // Angular components reference css files and their imports using raw-loader
                { test: /\.css$/, exclude: /[\/|\\]app\.css$/, use: "raw-loader" },
                { test: /\.scss$/, exclude: /[\/|\\]app\.scss$/, use: ["raw-loader", "resolve-url-loader", "sass-loader"] },

我曾尝试删除/hooks、/platform、package-lock.json、webpack.config.js和/ node_modules并进行重建-仍然遇到相同的错误。

我还尝试了带或不带/ variable /导入,或按不同顺序的app.scss文件的多个版本。

我已删除并重新添加了平台ios和平台android。

我已经搜索了几个小时,解决类似听起来问题的方法没有任何改变。

angular webpack sass nativescript
1个回答
0
投票

请参阅以下两个已报告的问题,这些问题目前可提供解决方法:https://github.com/NativeScript/nativescript-angular/issues/2174https://github.com/NativeScript/nativescript-dev-webpack/issues/1138

当我了解更多信息时,会回发。

© www.soinside.com 2019 - 2024. All rights reserved.