简体   繁体   English

Angular CLI'tsc'命令未在dist文件夹中复制index.html,nodemodules,css等

[英]Angular CLI 'tsc' command is not copying index.html, nodemodules, css, etc in the dist folder

I have Angular2 project created with CLI, the project is completed and I wanted to make all the *.js files, *js.map files, index.html/index.jsp, all the depending css, etc copied in the dist folder with proper architecture. 我有使用CLI创建的Angular2项目,该项目已完成,我想将所有* .js文件,* js.map文件,index.html / index.jsp,所有相关的CSS等复制到dist文件夹中,适当的架构。

Currently, if I invoked 'tsc' command, all the *.js and *js.map files are copied to dist but nodemodules folder, index.html/jsp and css files are not copied. 当前,如果我调用'tsc'命令,则所有* .js和* js.map文件都将复制到dist,但不会复制nodemodules文件夹,index.html / jsp和css文件。

I want these files to be copied there to deploy the dist content on server as browser only understand js and not the ts files. 我希望将这些文件复制到那里以在服务器上部署dist内容,因为浏览器仅了解js而不了解ts文件。

tsconfig : tsconfig

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2017",
      "dom"
    ]
  }

Package.json 的package.json

{
  "name": "query-builder",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^4.4.6",
    "@angular/common": "^4.2.4",
    "@angular/compiler": "^4.2.4",
    "@angular/core": "^4.2.4",
    "@angular/forms": "^4.2.4",
    "@angular/http": "^4.2.4",
    "@angular/platform-browser": "^4.2.4",
    "@angular/platform-browser-dynamic": "^4.2.4",
    "@angular/router": "^4.2.4",
    "angular-font-awesome": "^2.3.7",
    "bootstrap": "^3.3.7",
    "core-js": "^2.4.1",
    "font-awesome": "^4.7.0",
    "jQuery-QueryBuilder": "^2.4.4",
    "jquery": "^3.2.1",
    "primeng": "^4.2.2",
    "rxjs": "^5.4.2",
    "zone.js": "^0.8.14"
  },
  "devDependencies": {
    "@angular/cli": "1.4.9",
    "@angular/compiler-cli": "^4.2.4",
    "@angular/language-service": "^4.2.4",
    "@types/jasmine": "~2.5.53",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "~3.2.0",
    "jasmine-core": "~2.6.2",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "~1.7.0",
    "karma-chrome-launcher": "~2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~3.2.0",
    "tslint": "~5.7.0",
    "typescript": "~2.3.3"
  }
}

angular-cli.json 角cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "query-builder"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.app.json",
      "testTsconfig": "tsconfig.spec.json",
      "prefix": "app",
      "styles": [
        "../node_modules/primeng/resources/primeng.min.css",
        "../node_modules/primeng/resources/themes/omega/theme.css",
        "../node_modules/font-awesome/css/font-awesome.min.css",
        "../node_modules/bootstrap/dist/css/bootstrap.css",
        "../node_modules/jQuery-QueryBuilder/dist/css/query-builder.default.css",
        "../node_modules/jQuery-QueryBuilder/doc/css/bootstrap.min.css",
        "../src/app/selectizeFiles/selectize.bootstrap3.css",
        "../src/app/selectizeFiles/selectize.bootstrap2.css",
        "../src/app/selectizeFiles/selectize.css",
        "styles.css"
      ],
      "scripts": [
        "../node_modules/jquery/dist/jquery.min.js",
        "../node_modules/bootstrap/dist/js/bootstrap.min.js",
        "../node_modules/jQuery-QueryBuilder/dist/js/query-builder.standalone.min.js",
        "../src/app/selectizeFiles/selectize.js",
        "../src/app/selectizeFiles/selectize.min.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "src/tsconfig.app.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "src/tsconfig.spec.json",
      "exclude": "**/node_modules/**"
    },
    {
      "project": "e2e/tsconfig.e2e.json",
      "exclude": "**/node_modules/**"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "class": {
      "spec": false
    },
    "component": {}
  }
}

How can I make all the files copied to dist so as to deploy it directly on server? 如何将所有文件复制到dist,以便直接将其部署在服务器上?

With angular-cli you should be using the built in ng build command. 对于angular-cli,您应该使用内置的ng build命令。 This does all the compiling & bundling, and will output all the proper files to your dist directory. 这将完成所有编译和捆绑,并将所有正确的文件输出到dist目录。

It also has an option to build source maps ng build --sourcemaps=true 它还具有构建源映射的选项ng build --sourcemaps=true

I would read through all the options in their documentation to determine your exact needs( https://github.com/angular/angular-cli/wiki/build ) 我会仔细阅读他们文档中的所有选项,以确定您的确切需求( https://github.com/angular/angular-cli/wiki/build

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM