index.html находится в dist / src, но файлы bundle.js находятся в dist. Не в состоянии найти файлы bundle.js - PullRequest
1 голос
/ 02 октября 2019

Я строю свой проект с помощью angular-cli и столкнулся с проблемой, когда index.html встраивается в файлы dist / src, а bundle.js находится в папке dist. Таким образом, index.html не может найти файлы bundle.js в браузере. Я использую yarn watch.

Попытался изменить мой файл .angular-json, но он все еще помещает index.html в папку src в dist.

.angular-cli.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "project": {
    "name": "redis-cli"
  },
  "apps": [
    {
      "root": "",
      "outDir": "dist",
      "assets": [
        "assets",
        "web.config",
        "favicon.ico",
        "common",
        "modules"
      ],
      "index": "src/index.html",
      "main": "src/main.ts",
      "polyfills": "src/polyfills.ts",
      "test": "src/test.ts",
      "tsconfig": "tsconfig.json",
      "testTsconfig": "src/tsconfig.spec.json",
      "styles": [
        "src/styles/main.css",
        "src/styles/custom.css",
        "src/styles/bootstrap.css",
        "src/styles/login-custom.css",
        "src/styles/login-custom-ext.css"
      ],
      "scripts": [
        "./node_modules/jquery/dist/jquery.min.js",
        "./node_modules/angular/angular.min.js"
      ],
      "environmentSource": "environments/environment.ts",
      "environments": {
        "dev": "environment/environment.ts",
        "prod": "environment/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "project": "tsconfig.json"
    },
    {
      "project": "src/tsconfig.spec.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  }
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "dist",
    "sourceMap": true,
    "module": "es2015",
    "allowJs": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "noStrictGenericChecks": true,
    "allowSyntheticDefaultImports": true,
    "removeComments": false,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "suppressImplicitAnyIndexErrors": true,
    "outputHashing": "all",
    "extractCss": true,
    "namedChunks": false,
    "buildOptimizer": false,
    "baseUrl": ".",
    "target": "es5",
    "files": [
      "node_modules/moment/moment.d.ts"
    ],
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es6",
      "dom",
      "scripthost"
    ],
    "types": [
      "node",
      "google.analytics",
      "jquery"
    ],
    "paths": {
      "@tet/*": [
        "src/modules/*",
        "./../tetris-web/common/app/modules/*"
      ],
      "@angular/*": ["./node_modules/@angular/*"]
    },
    "exclude": [
      "node_modules"
    ]
  }
}

package.json

{
  "name": "redis-cli",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "node ./node_modules/@angular/cli/bin/ng",
    "build": "npm run ng -- build",
    "serve": "npm run ng -- serve --proxy-config proxy.conf.js --base-href /",
    "watch": "npm run build -- --watch"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "2.4.10",
    "@angular/compiler": "2.4.10",
    "@angular/core": "2.4.10",
    "@angular/forms": "2.4.10",
    "@angular/http": "2.4.10",
    "@angular/platform-browser": "2.4.10",
    "@angular/platform-browser-dynamic": "2.4.10",
    "@angular/platform-server": "2.4.10",
    "@angular/router": "3.4.10",
    "@angular/upgrade": "2.4.10",
    "@uirouter/angularjs": "^1.0.22",
    "angular": "1.7.8",
    "bootstrap-sass": "^3.3.7",
    "codelyzer": "4.4.4",
    "core-js": "2.5.3",
    "crypto-js": "3.1.9-1",
    "cryptojslib": "~3.1.2",
    "daterangepicker": "^3.0.3",
    "enhanced-resolve": "^3.3.0",
    "eslint": "^3.9.1",
    "eslint-html-reporter": "^0.5.2",
    "eslint-plugin-angular": "^1.4.1",
    "eslint-plugin-nortal": "0.0.1",
    "fileapi": "2.0.25",
    "font-awesome": "^4.7.0",
    "html-webpack-plugin": "3.0.7",
    "intl": "^1.2.5",
    "isikukood": "1.2.3",
    "jquery": "^3.3.1",
    "lodash": "3.10.1",
    "message-center": "^0.1.10",
    "moment": "2.9.0",
    "ng-file-upload": "3.2.*",
    "ng-table": "0.5.*",
    "ngx-bootstrap": "1.6.2",
    "oi.select": "^0.2.21",
    "pako": "1.0.6",
    "postcss-loader": "2.0.8",
    "reflect-metadata": "0.1.2",
    "rxjs": "^5.0.1",
    "split.js": "^1.3.5",
    "tsconfig-paths-webpack-plugin": "3.2.0",
    "ua-parser-js": "0.7.18",
    "ui-router": "^1.0.0-alpha.3",
    "web-animations-js": "^2.3.2",
    "yarn": "^1.17.3",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "1.7.4",
    "@angular/compiler-cli": "2.4.10",
    "@types/google.analytics": "0.0.39",
    "@types/jquery": "<3.3.28",
    "@types/node": "^12.0.5",
    "angular2-template-loader": "^0.6.0",
    "awesome-typescript-loader": "^3.0.4",
    "css-loader": "^0.26.1",
    "file-loader": "^4.2.0",
    "grunt": "0.4.0",
    "html-loader": "^0.4.3",
    "mini-css-extract-plugin": "0.8.0",
    "to-string-loader": "^1.1.5",
    "tsconfig-paths-webpack-plugin": "3.2.0",
    "tslint": "^5.0.0",
    "typescript": "2.6.1"
  }
}

То, что я хочу, это то, чтоindex.html будет расположен в dist, а src не будет в dist, поэтому index.html может найти файлы bundle.js.

...