[英]Angular2: Rollupjs bundle with relative paths in component class
To support i18n as explained here I have to support AOT and therefore need to use relative templateUrl
and styleUrls
in my components and set moduleId: module.id
. 为了支持国际化的解释在这里我要支持AOT,因此需要使用相对
templateUrl
和styleUrls
在我的组件和设置moduleId: module.id
。
This works perfect for my dev build which does not bundle and loads the files using systemjs (built using gulp) 这适用于我的dev构建,它不使用systemjs捆绑和加载文件(使用gulp构建)
In the production build I use rollup.js to tree-shake and bundle. 在生产构建中,我使用rollup.js进行树抖动和捆绑。 Here I have to compliation steps since rollup needs es2015 modules and the browser (and to have module.id set in the components) needs common.js
在这里我必须补充步骤,因为汇总需要es2015模块和浏览器(以及在组件中设置module.id)需要common.js
target: es5, module: es2015
target: es5, module: es2015
: target: es5, module: es2015
format: iife
format: iife
target: es5, module: commonjs, allowJs: true
target: es5, module: commonjs, allowJs: true
Doing that I get the following error when running the app: failed to load app.component.html 这样做我在运行应用程序时遇到以下错误: 无法加载app.component.html
Version info: 版本信息:
Does anyone have an idea what is causing the problem? 有谁知道导致问题的原因是什么? Thanks a lot for your help
非常感谢你的帮助
when you use module.id you have to declare a variable on the component for modules. 当您使用module.id时,您必须在模块的组件上声明一个变量。 that is:
那是:
declare var module: any;
import { Component } from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app',
templateUrl: 'content.component.html'
})
export class ContentComponent {}
I hope this works for you 我希望这适合你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.