[英]How can separate js files and ts files automatically in angular after npm start?
Can I get this result modifying tsconfig.json or package.json? 修改tsconfig.json或package.json可以得到此结果吗?
I want this structure: 我想要这样的结构:
angular2-quickstart
app
ts
app.component.ts
main.ts
js
app.component.js
app.component.js.map
main.js
main.js.map
index.html
license.md
no this: 没有这个:
angular2-quickstart
app
app.component.ts
main.ts
app.component.js
app.component.js.map
main.js
main.js.map
index.html
license.md
Yes, you can tell the TypeScript compiler to output .js
files to a different directory using the outDir
option in tsconfig.json
, and I'd recommend setting the rootDir
too so as to avoid unpleasant surprises in the future: 是的,你可以告诉编译器打字稿输出
.js
文件使用一个不同的目录outDir
在选项tsconfig.json
,我建议你设置rootDir
过,从而避免在未来不愉快的意外:
{
"compilerOptions": {
"outDir": "app/js",
"rootDir": "app/ts",
}
}
Don't forget to adjust paths in index.html
. 不要忘记调整
index.html
路径。
If you want to separate out .js and .ts files in angular2, you have to follow only two steps:- 如果要在angular2中分离出.js和.ts文件,则只需执行以下两个步骤:
1) Add "outDir":"<folder name where you want to put your js Files>"
within compilerOptions object in tsconfig.json
file. 1)在
tsconfig.json
文件的compilerOptions对象中添加"outDir":"<folder name where you want to put your js Files>"
。
2) Map your folder in systemjs.config.js
ie modify the map object like 2)在
systemjs.config.js
映射您的文件夹,即修改映射对象,例如
map:{
app:<Folder-Name which you have specified in outDir>
----
----
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.