Angular 2 Typescript编译器复制html和css文件
在Angular2我会有
"outDir": "dist/app" 在tsconfig.json.因此,在/ dist / app /文件夹和/或其子文件夹中生成了.iled和.map文件.这一切都很好. 在我的components.ts文件中,我也使用了这样引用的html和css @Component({ selector: 'my-app',templateUrl: 'app/appshell/app.component.html',styleUrls: ['app/appshell/app.component.css'],...... } 有没有办法使编译器也复制整个项目的引用的html和css文件? 我查看了这里的编译器选项https://www.typescriptlang.org/docs/handbook/compiler-options.html,但没有找到有关复制html / css文件的任何内容. 更新: Root |--app // for ts |--dist/app // for js tsconfig.json "outDir": "dist/app" 的package.json { "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 ;",...... } 它不复制html文件.没有错误. 再次更新: 对于那些在Linux操作系统上的人来说,Bernardo的解决方案是一个工作的解决方案. "scripts": { "html": "XCOPY /S /y .app*.html .distapp" }
不,TypeScript编译器只适用于* .ts文件.
您必须使用复制方法(例如cpm shell命令)复制其他文件,如* .html和* .css,例如npm脚本或grunt-contrib-copy. 使用npm脚本的示例: "scripts": { "html": "find ./app -name '*.html' -type f -exec cp --parents {} ./dist ;" } 只需运行npm在shell中运行html. 使用grunt的例子: copy: { html: { src: ['**/*.html'],dest: 'dist',cwd: 'app',expand: true,} } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |