How to connect Angular2 + Webpack + Node + Express?

First of all, I connected and worked, but I'm a little dissatisfied with the result and I feel that it can be improved.

(The current result can be found here - https://github.com/MarkKharitonov/Angular2WebpackNodeExpress/tree/v0.0.1 .)

Directory structure:

C:.
β”‚   .gitignore
β”‚   package.json
β”‚   tsconfig.json
β”‚   tslint.json
β”‚   typings.json
β”‚   webpack.config.js
β”‚
β”œβ”€β”€β”€dist
β”‚   └───server
β”‚           api.js
β”‚           api.js.map
β”‚           main.js
β”‚           main.js.map
β”‚
└───src
    β”œβ”€β”€β”€client
    β”‚       app.component.ts
    β”‚       index.html
    β”‚       main.ts
    β”‚       polyfills.ts
    β”‚       tsconfig.json
    β”‚       vendor.ts
    β”‚
    └───server
            api.ts
            main.ts
            tsconfig.json

Currently, the folder distcontains only server-side files compiled from ./src/server. They are hosted there by IntelliJ IDEA because it ./src/server/tsconfig.jsonrequests compilation on save.

Client-side linking occurs in the memory provided by the webpack-dev server. The command ./src/client/tsconfig.json does not compile the request when saving.

- https://github.com/MarkKharitonov/Angular2WebpackNodeExpress/tree/v0.0.1#problems, :

  • Webpack .js ./src/client - ./dist/client . .js . /src/server? (gulp, grunt, ...) webpack?
  • tsconfig.json - ./src/client/tsconfig.json, ./src/server/tsconfig.json ./tsconfig.json. , . - .
  • , , TypeScript (.\src\client\main.ts, .\src\client\polyfills.ts, .\src\client\vendor.ts .\src\server\main.ts) /// <reference path="../../typings/index.d.ts" />.

, :

  • webpack , , ? transpile - , dist - , - ? , , webpack-dev-.
  • tsconfig.json, , ?
  • /// <reference path="../../typings/index.d.ts" /> TypeScript, ?

, , , , .

+4
1
+1

Source: https://habr.com/ru/post/1651616/


All Articles