我正在尝试使用Angular Element使用Angular 7生成自定义元素,但是将其放到一个大文件中(包括运行时,polyfills,脚本和main)时,生成的文件将产生错误(ERROR错误:选择器“ app -root”与任何元素均不匹配)
这是我的构建脚本
// build-elements.js
const fs = require('fs-extra');
const concat = require('concat');
(async function build() {
const files = [
'./dist/elements/runtime.js',
'./dist/elements/polyfills.js',
'./dist/elements/scripts.js',
'./dist/elements/main.js',
]
await fs.ensureDir('elements')
await concat(files, 'elements/elements.js');
await fs.copyFile('./dist/elements/styles.css', 'elements/styles.css')
})()
该项目与从官方文档下载的相同 https://angular.io/guide/elements
为了生成Web组件,我使用以下命令:
> ng build elements --prod && node build-elements.js
那是索引文件
<!doctype html>
<html lang="en">
<head>
<!-- Here I include the CSS and JS for my custom elements -->
<link rel="stylesheet" type="text/css" href="./styles.css">
<script src="./elements.js"></script>
</head>
<body>
<div>
Here is an Angular Element:
<popup-element></popup-element>
</div>
</body>
</html>
有人知道我想念什么?谢谢。