加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

将Angular2 TypeScript文件和JavaScript文件分隔到不同的文件夹

发布时间:2020-12-17 09:00:55 所属栏目:安全 来源:网络整理
导读:我使用来自angular.io网站的 5 min quickstart,其中包含这样的文件结构: angular2-quickstart app app.component.ts boot.ts index.html license.md package.json tsconfig.json tsconfig.json是一个像这样的代码块: { "compilerOptions": { "target": "E
我使用来自angular.io网站的 5 min quickstart,其中包含这样的文件结构:
angular2-quickstart
 app
   app.component.ts
   boot.ts
 index.html
 license.md
 package.json
 tsconfig.json

tsconfig.json是一个像这样的代码块:

{
  "compilerOptions": {
    "target": "ES5","module": "system","moduleResolution": "node","sourceMap": true,"emitDecoratorMetadata": true,"experimentalDecorators": true,"removeComments": false,"noImplicitAny": false
  },"exclude": [
    "node_modules"
  ]
}

还有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文件。

我想只工作ts文件,不想获得早午餐的js和js.map文件,我应该做什么把所有我的ts文件在我的常规开发floder像app文件夹和所有的js和js。映射文件到一个名为dist的文件夹?

一个很好的例子可能是angular2-webpack-quickstart.但我没有想出他们是怎么做的?

任何建议如何做到,当然不是手动。

谢谢,

可能晚了,但这里是一个两步的解决方案。

步骤1

将“app”更新为“dist / app”,更改system.config.js:

var  map = {
    'app':                        'app',// 'dist/app',.
    .
    .
};

现在它将看起来像这样:

var  map = {
    'app':                        'dist/app',.
    .
    .
};

第2步

创建dist文件夹。
编辑tsconfig.json并添加:

"outDir": "dist"

生成的tsconfig.json:

{
  "compilerOptions": {
    .
    .
    .
    .

    "outDir": "dist" // Pay attention here
  },"exclude": [
    .
    .
    .
  ]
}

运行npm start,你应该在dist文件夹中看到所有编译的.js和.map.js文件。

注意:查看其他答案。他们是非常有用和信息。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读