将Angular2 TypeScript文件和JavaScript文件分隔到不同的文件夹中,可能是'dist' [英] Separate Angular2 TypeScript files and JavaScript files into different folders, maybe 'dist‘
问题描述
我正在使用angular.io网站上的 5分钟快速入门,其中包含类似的文件结构这个:
I am using the 5 min quickstart from angular.io website, which contain a file structure like this:
angular2-quickstart
app
app.component.ts
boot.ts
index.html
license.md
package.json
tsconfig.json
tsconfig.json是这样的代码块:
the tsconfig.json is a code block like this :
{
"compilerOptions": {
"target": "ES5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules"
]
}
此外, package.json:
Also the package.json:
{
"name": "angular2-quickstart",
"version": "1.0.0",
"scripts": {
"tsc": "tsc",
"tsc:w": "tsc -w",
"lite": "lite-server",
"start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
},
"license": "ISC",
"dependencies": {
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"concurrently": "^1.0.0",
"lite-server": "^1.3.1",
"typescript": "^1.7.3"
}
}
我将sourceMap从true更改为false,因此在代码编辑器中,不会再次生成映射文件,但仍会生成js文件。
I change the sourceMap from true to false, so in the code editor, the map file is not generated again, but the js file still get generated.
我想只处理ts文件并且不想获得js和js.map文件的早午餐,我应该怎么做才能把我所有的ts文件在我的常规开发floder如app文件夹和所有js和js.map文件到一个名为dist的文件夹中?
I want to work on only ts file and don't want to get a brunch of js and js.map file, what should I do to put all my ts files in my regular develop floder like app folder and all the js and js.map files into a folder called dist?
一个很好的例子可能是angular2-webpack-quickstart 。但是我没弄明白他们是怎么做到的?
A good example of this might be angular2-webpack-quickstart. But I didn't figure out how they do that?
任何建议如何做,当然不是手动。
Any advice how to do that, of course not manually.
谢谢,
推荐答案
可能迟到了,但这是一个两步解决方案。
Probably late but here is a two-step solution.
通过更新'app'更改 system.config.js
到'dist / app'
:
var map = {
'app': 'app', // 'dist/app',
.
.
.
};
现在看起来像这样:
var map = {
'app': 'dist/app', // 'dist/app',
.
.
.
};
第2步
创建 dist 文件夹。
编辑 tsconfig.json 并添加:
Step 2
Create the dist folder.
Edit tsconfig.json and add:
"outDir": "dist"
结果 tsconfig.json
:
{
"compilerOptions": {
.
.
.
.
"outDir": "dist" // Pay attention here
},
"exclude": [
.
.
.
]
}
运行 npm start
你应该在 .js 和 .map.js
文件> dist 文件夹。
Run npm start
and you should see all the compiled .js
and .map.js
files in the dist folder.
注意:查看其他答案。它们非常有用且信息丰富。
Note: Go through other answers. They are quite useful and informative too.
这篇关于将Angular2 TypeScript文件和JavaScript文件分隔到不同的文件夹中,可能是'dist'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!