在Angular2我会有
@H_404_1@"outDir": "dist/app"
在tsconfig.json.因此,在/ dist / app /文件夹和/或其子文件夹中生成了.iled和.map文件.这一切都很好.
在我的components.ts文件中,我也使用了这样引用的html和css
@H_404_1@@Component({ selector: 'my-app',templateUrl: 'app/appshell/app.component.html',styleUrls: ['app/appshell/app.component.css'],...... }有没有办法使编译器也复制整个项目的引用的html和css文件?
如果是,我该如何配置我的tsconfig.json?
我查看了这里的编译器选项https://www.typescriptlang.org/docs/handbook/compiler-options.html,但没有找到有关复制html / css文件的任何内容.
更新:
我的文件夹结构是这样的
tsconfig.json
@H_404_1@"outDir": "dist/app"的package.json
@H_404_1@{ "name": "TestApp","version": "1.0.0","scripts": { "start": "tsc && concurrently \"tsc -w\" \"lite-server\" ","html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist \\;",...... }再次更新:
对于那些在Linux操作系统上的人来说,Bernardo的解决方案是一个工作的解决方案.
对于那些在Windows操作系统上的人来说,以下应该是正常的.
不,TypeScript编译器只适用于* .ts文件.
您必须使用复制方法(例如cpm shell命令)复制其他文件,如* .html和* .css,例如npm脚本或grunt-contrib-copy.
使用npm脚本的示例:
@H_404_1@"scripts": { "html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist \\;" }只需运行npm在shell中运行html.
使用grunt的例子:
@H_404_1@copy: { html: { src: ['**/*.html'],dest: 'dist',cwd: 'app',expand: true,} }