在Angular 5中导出UI组件-未找到模板
我正在开发UI组件,用于整个公司的不同Web项目。我们希望在本地存储库中将ui组件发布为npm包。发布包 当我npm安装软件包时,在我的在Angular 5中导出UI组件-未找到模板,angular,typescript,rollup,Angular,Typescript,Rollup,我正在开发UI组件,用于整个公司的不同Web项目。我们希望在本地存储库中将ui组件发布为npm包。发布包 当我npm安装软件包时,在我的app.module.ts中导入模块并运行“ng serve”(这是一个Angular CLI项目),一切都可以正常编译。但在本地主机上访问站点时,不会显示任何内容,控制台会显示: 在编译和打包模板时,Angular为什么要寻找html格式的模板?以及如何告知CLI这些组件已编译? tsconfig.json(打包前) 我在网上找不到angularCompi
app.module.ts
中导入模块并运行“ng serve”(这是一个Angular CLI项目),一切都可以正常编译。但在本地主机上访问站点时,不会显示任何内容,控制台会显示:
在编译和打包模板时,Angular为什么要寻找html格式的模板?以及如何告知CLI这些组件已编译?
tsconfig.json(打包前) 我在网上找不到angularCompilerOptions的文档
node_modules
中的npm包是:
我通过在
button.component.ngfactory.js中搜索CSS类找到了按钮模板,但导出的ButtonComponentNgFactory
似乎没有导入任何地方。我无法实现这一点,但另一种方法非常有效-它将模板打包成不同的js格式,并完成了所有工作:
{
"compilerOptions": {
"baseUrl": ".",
"declaration": true,
"stripInternal": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictNullChecks": true,
"noImplicitAny": true,
"module": "es2015",
"moduleResolution": "node",
"paths": {
"@angular/core": ["node_modules/@angular/core"],
"@angular/common": ["node_modules/@angular/common"],
"@angular/forms": ["node_modules/@angular/forms"],
"@ng-bootstrap/ng-bootstrap": ["node_modules/@ng-bootstrap/ng-bootstrap"]
},
"rootDir": ".",
"outDir": "dist",
"sourceMap": true,
"inlineSources": true,
"target": "es5",
"skipLibCheck": true,
"lib": [
"es2015",
"dom"
]
},
"files": [
"index.ts"
],
"angularCompilerOptions": {
"strictMetadataEmit": true
}
}