我正在尝试使用https://docs.nativescript.org/performance-optimizations/bundling-with-webpack这些说明在我的本机脚本应用程序中启动和运行Webpack。
命令tns运行android可以正常工作,但是当我尝试运行tns运行android --bundle时,一切都会变得很混乱。
我收到的所有错误消息都是一样的,其中一个看起来像这样
ERROR in ./pages/settings/settings.component.ts
Module not found: Error: Can't resolve './pages/settings/settings.html' in
'C:\Users\stull\Desktop\forritun\SecondLudusApp\app\pages\settings'
@./pages/settings/settings.component.ts 171:22-63
@./app.routing.ts
@./app.module.ts
@./main.ts
最后我收到此消息
Webpack compilation complete.
Unable to apply changes on device: "devicename". Error is: Executing webpack
failed with exit code 2..
Executing after-watch hook from "path"
Stopping tsc watch
Executing after-watch hook from "path"
有人有类似的问题并设法解决吗?
如果有帮助,这也是我的tsconfig.json文件
{
"compilerOptions": {
"target": "es5",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": false,
"noEmitOnError": true,
"lib": [
"es6",
"es5",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"*": [
"./node_modules/tns-core-modules/*",
"./node_modules/*"
]
}
},
"exclude": [
"node_modules",
"platforms",
"**/*.aot.ts"
]
}
答案 0 :(得分:0)
我发现了问题所在。
运行tns并运行android允许我做
templateUrl: "pages/something/something.html"
使用webpack运行不接受这种书写风格。 接受该版本
templateUrl: "./something.html"
对于我必须从另一个组件中使用的css文件,
styleUrls: ["./../otherComponent/otherComponent.html"]