Browse Source

Moved /app to /client

update-deps
Alex Mikhalev 7 years ago
parent
commit
dd39980c74
  1. 8
      client/components/App.tsx
  2. 10
      client/components/DeviceView.tsx
  3. 2
      client/components/DevicesView.tsx
  4. 2
      client/components/DurationView.tsx
  5. 2
      client/components/MessageTest.tsx
  6. 4
      client/components/MessagesView.tsx
  7. 4
      client/components/NavBar.tsx
  8. 4
      client/components/ProgramSequenceView.tsx
  9. 4
      client/components/ProgramTable.tsx
  10. 4
      client/components/RunSectionForm.tsx
  11. 0
      client/components/ScheduleView/ScheduleDate.tsx
  12. 0
      client/components/ScheduleView/ScheduleTimes.tsx
  13. 0
      client/components/ScheduleView/TimeInput.tsx
  14. 0
      client/components/ScheduleView/WeekdaysView.tsx
  15. 2
      client/components/ScheduleView/index.tsx
  16. 2
      client/components/SectionChooser.tsx
  17. 2
      client/components/SectionRunnerView.tsx
  18. 0
      client/components/SectionTable.tsx
  19. 0
      client/components/index.ts
  20. 0
      client/images/favicon-16x16.png
  21. 0
      client/images/favicon-32x32.png
  22. 0
      client/images/favicon-96x96.png
  23. 0
      client/images/favicon.ico
  24. 0
      client/images/raspberry_pi.png
  25. 0
      client/index.html
  26. 8
      client/index.tsx
  27. 4
      client/pages/LoginPage.tsx
  28. 2
      client/pages/LogoutPage.tsx
  29. 6
      client/pages/ProgramPage.tsx
  30. 2
      client/pages/index.tsx
  31. 0
      client/polyfills.js
  32. 0
      client/routePaths.ts
  33. 2
      client/sprinklersRpc/WebSocketRpcClient.ts
  34. 6
      client/state/AppState.ts
  35. 2
      client/state/HttpApi.ts
  36. 0
      client/state/Token.ts
  37. 4
      client/state/TokenStore.ts
  38. 0
      client/state/UiStore.ts
  39. 0
      client/state/index.ts
  40. 2
      client/state/reactContext.tsx
  41. 0
      client/styles/DeviceView.scss
  42. 0
      client/styles/DurationView.scss
  43. 0
      client/styles/LoginPage.scss
  44. 0
      client/styles/MessagesView.scss
  45. 0
      client/styles/ProgramSequenceView.scss
  46. 0
      client/styles/ScheduleView.scss
  47. 0
      client/styles/SectionChooser.scss
  48. 0
      client/styles/SectionRunnerView.scss
  49. 0
      client/styles/app.scss
  50. 4
      client/tsconfig.json
  51. 16
      client/webpack.config.js
  52. 12
      common/paths.js
  53. 4
      common/tsconfig.json
  54. 2
      docker-compose.dev.yml
  55. 8
      package.json
  56. 2
      server/express/serveApp.ts
  57. 4
      server/tsconfig.json

8
app/components/App.tsx → client/components/App.tsx

@ -3,14 +3,14 @@ import * as React from "react";
import { Redirect, Route, Switch } from "react-router"; import { Redirect, Route, Switch } from "react-router";
import { Container } from "semantic-ui-react"; import { Container } from "semantic-ui-react";
import { MessagesView, NavBar } from "@app/components"; import { MessagesView, NavBar } from "@client/components";
import * as p from "@app/pages"; import * as p from "@client/pages";
import * as rp from "@app/routePaths"; import * as rp from "@client/routePaths";
// tslint:disable:ordered-imports // tslint:disable:ordered-imports
import "font-awesome/css/font-awesome.css"; import "font-awesome/css/font-awesome.css";
import "semantic-ui-css/semantic.css"; import "semantic-ui-css/semantic.css";
import "@app/styles/app"; import "@client/styles/app";
function NavContainer() { function NavContainer() {
return ( return (

10
app/components/DeviceView.tsx → client/components/DeviceView.tsx

@ -3,14 +3,14 @@ import { observer } from "mobx-react";
import * as React from "react"; import * as React from "react";
import { Grid, Header, Icon, Item, SemanticICONS } from "semantic-ui-react"; import { Grid, Header, Icon, Item, SemanticICONS } from "semantic-ui-react";
import * as p from "@app/pages"; import * as p from "@client/pages";
import * as rp from "@app/routePaths"; import * as rp from "@client/routePaths";
import { AppState, injectState } from "@app/state"; import { AppState, injectState } from "@client/state";
import { ConnectionState as ConState } from "@common/sprinklersRpc"; import { ConnectionState as ConState } from "@common/sprinklersRpc";
import { Route, RouteComponentProps, withRouter } from "react-router"; import { Route, RouteComponentProps, withRouter } from "react-router";
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from "."; import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
import "@app/styles/DeviceView"; import "@client/styles/DeviceView";
const ConnectionState = observer(({ connectionState, className }: const ConnectionState = observer(({ connectionState, className }:
{ connectionState: ConState, className?: string }) => { { connectionState: ConState, className?: string }) => {
@ -72,7 +72,7 @@ class DeviceView extends React.Component<DeviceViewProps & RouteComponentProps<a
); );
return ( return (
<Item> <Item>
<Item.Image src={require("@app/images/raspberry_pi.png")} /> <Item.Image src={require("@client/images/raspberry_pi.png")} />
<Item.Content className="device"> <Item.Content className="device">
<Header as="h1"> <Header as="h1">
<div>Device <kbd>{id}</kbd></div> <div>Device <kbd>{id}</kbd></div>

2
app/components/DevicesView.tsx → client/components/DevicesView.tsx

@ -2,7 +2,7 @@ import { observer } from "mobx-react";
import * as React from "react"; import * as React from "react";
import { Item } from "semantic-ui-react"; import { Item } from "semantic-ui-react";
import DeviceView from "@app/components/DeviceView"; import DeviceView from "@client/components/DeviceView";
import { RouteComponentProps, withRouter } from "react-router"; import { RouteComponentProps, withRouter } from "react-router";
class DevicesView extends React.Component<{deviceId: string} & RouteComponentProps<any>> { class DevicesView extends React.Component<{deviceId: string} & RouteComponentProps<any>> {

2
app/components/DurationView.tsx → client/components/DurationView.tsx

@ -4,7 +4,7 @@ import { Form, Input, InputProps } from "semantic-ui-react";
import { Duration } from "@common/Duration"; import { Duration } from "@common/Duration";
import "@app/styles/DurationView"; import "@client/styles/DurationView";
export default class DurationView extends React.Component<{ export default class DurationView extends React.Component<{
label?: string, label?: string,

2
app/components/MessageTest.tsx → client/components/MessageTest.tsx

@ -1,7 +1,7 @@
import * as React from "react"; import * as React from "react";
import { Button, Segment } from "semantic-ui-react"; import { Button, Segment } from "semantic-ui-react";
import { AppState, injectState } from "@app/state"; import { AppState, injectState } from "@client/state";
import { getRandomId } from "@common/utils"; import { getRandomId } from "@common/utils";
class MessageTest extends React.Component<{ appState: AppState }> { class MessageTest extends React.Component<{ appState: AppState }> {

4
app/components/MessagesView.tsx → client/components/MessagesView.tsx

@ -3,9 +3,9 @@ import { observer } from "mobx-react";
import * as React from "react"; import * as React from "react";
import { Message, MessageProps, TransitionGroup } from "semantic-ui-react"; import { Message, MessageProps, TransitionGroup } from "semantic-ui-react";
import { AppState, injectState, UiMessage, UiStore } from "@app/state/"; import { AppState, injectState, UiMessage, UiStore } from "@client/state/";
import "@app/styles/MessagesView"; import "@client/styles/MessagesView";
@observer @observer
class MessageView extends React.Component<{ class MessageView extends React.Component<{

4
app/components/NavBar.tsx → client/components/NavBar.tsx

@ -3,8 +3,8 @@ import * as React from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Menu } from "semantic-ui-react"; import { Menu } from "semantic-ui-react";
import * as rp from "@app/routePaths"; import * as rp from "@client/routePaths";
import { AppState, ConsumeState, injectState } from "@app/state"; import { AppState, ConsumeState, injectState } from "@client/state";
interface NavItemProps { interface NavItemProps {
to: string; to: string;

4
app/components/ProgramSequenceView.tsx → client/components/ProgramSequenceView.tsx

@ -4,11 +4,11 @@ import * as React from "react";
import { SortableContainer, SortableElement, SortableHandle, SortEnd } from "react-sortable-hoc"; import { SortableContainer, SortableElement, SortableHandle, SortEnd } from "react-sortable-hoc";
import { Button, Form, Icon, List } from "semantic-ui-react"; import { Button, Form, Icon, List } from "semantic-ui-react";
import { DurationView, SectionChooser } from "@app/components/index"; import { DurationView, SectionChooser } from "@client/components/index";
import { Duration } from "@common/Duration"; import { Duration } from "@common/Duration";
import { ProgramItem, Section } from "@common/sprinklersRpc"; import { ProgramItem, Section } from "@common/sprinklersRpc";
import "@app/styles/ProgramSequenceView"; import "@client/styles/ProgramSequenceView";
type ItemChangeHandler = (index: number, newItem: ProgramItem) => void; type ItemChangeHandler = (index: number, newItem: ProgramItem) => void;
type ItemRemoveHandler = (index: number) => void; type ItemRemoveHandler = (index: number) => void;

4
app/components/ProgramTable.tsx → client/components/ProgramTable.tsx

@ -4,8 +4,8 @@ import * as React from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import { Button, ButtonProps, Form, Icon, Table } from "semantic-ui-react"; import { Button, ButtonProps, Form, Icon, Table } from "semantic-ui-react";
import { ProgramSequenceView, ScheduleView } from "@app/components"; import { ProgramSequenceView, ScheduleView } from "@client/components";
import * as rp from "@app/routePaths"; import * as rp from "@client/routePaths";
import { Program, SprinklersDevice } from "@common/sprinklersRpc"; import { Program, SprinklersDevice } from "@common/sprinklersRpc";
@observer @observer

4
app/components/RunSectionForm.tsx → client/components/RunSectionForm.tsx

@ -2,8 +2,8 @@ import { observer } from "mobx-react";
import * as React from "react"; import * as React from "react";
import { Form, Header, Icon, Segment } from "semantic-ui-react"; import { Form, Header, Icon, Segment } from "semantic-ui-react";
import { DurationView, SectionChooser } from "@app/components"; import { DurationView, SectionChooser } from "@client/components";
import { UiStore } from "@app/state"; import { UiStore } from "@client/state";
import { Duration } from "@common/Duration"; import { Duration } from "@common/Duration";
import log from "@common/logger"; import log from "@common/logger";
import { Section, SprinklersDevice } from "@common/sprinklersRpc"; import { Section, SprinklersDevice } from "@common/sprinklersRpc";

0
app/components/ScheduleView/ScheduleDate.tsx → client/components/ScheduleView/ScheduleDate.tsx

0
app/components/ScheduleView/ScheduleTimes.tsx → client/components/ScheduleView/ScheduleTimes.tsx

0
app/components/ScheduleView/TimeInput.tsx → client/components/ScheduleView/TimeInput.tsx

0
app/components/ScheduleView/WeekdaysView.tsx → client/components/ScheduleView/WeekdaysView.tsx

2
app/components/ScheduleView/index.tsx → client/components/ScheduleView/index.tsx

@ -7,7 +7,7 @@ import ScheduleDate from "./ScheduleDate";
import ScheduleTimes from "./ScheduleTimes"; import ScheduleTimes from "./ScheduleTimes";
import WeekdaysView from "./WeekdaysView"; import WeekdaysView from "./WeekdaysView";
import "@app/styles/ScheduleView"; import "@client/styles/ScheduleView";
export interface ScheduleViewProps { export interface ScheduleViewProps {
label?: string | React.ReactNode | undefined; label?: string | React.ReactNode | undefined;

2
app/components/SectionChooser.tsx → client/components/SectionChooser.tsx

@ -5,7 +5,7 @@ import { DropdownItemProps, DropdownProps, Form } from "semantic-ui-react";
import { Section } from "@common/sprinklersRpc"; import { Section } from "@common/sprinklersRpc";
import "@app/styles/SectionChooser"; import "@client/styles/SectionChooser";
@observer @observer
export default class SectionChooser extends React.Component<{ export default class SectionChooser extends React.Component<{

2
app/components/SectionRunnerView.tsx → client/components/SectionRunnerView.tsx

@ -7,7 +7,7 @@ import { Duration } from "@common/Duration";
import log from "@common/logger"; import log from "@common/logger";
import { Section, SectionRun, SectionRunner } from "@common/sprinklersRpc"; import { Section, SectionRun, SectionRunner } from "@common/sprinklersRpc";
import "@app/styles/SectionRunnerView"; import "@client/styles/SectionRunnerView";
interface PausedStateProps { interface PausedStateProps {
paused: boolean; paused: boolean;

0
app/components/SectionTable.tsx → client/components/SectionTable.tsx

0
app/components/index.ts → client/components/index.ts

0
app/images/favicon-16x16.png → client/images/favicon-16x16.png

Before

Width:  |  Height:  |  Size: 955 B

After

Width:  |  Height:  |  Size: 955 B

0
app/images/favicon-32x32.png → client/images/favicon-32x32.png

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

0
app/images/favicon-96x96.png → client/images/favicon-96x96.png

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

0
app/images/favicon.ico → client/images/favicon.ico

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

0
app/images/raspberry_pi.png → client/images/raspberry_pi.png

Before

Width:  |  Height:  |  Size: 216 KiB

After

Width:  |  Height:  |  Size: 216 KiB

0
app/index.html → client/index.html

8
app/index.tsx → client/index.tsx

@ -3,8 +3,8 @@ import * as ReactDOM from "react-dom";
import { AppContainer } from "react-hot-loader"; import { AppContainer } from "react-hot-loader";
import { Router } from "react-router-dom"; import { Router } from "react-router-dom";
import App from "@app/components/App"; import App from "@client/components/App";
import { AppState, ProvideState } from "@app/state"; import { AppState, ProvideState } from "@client/state";
import logger from "@common/logger"; import logger from "@common/logger";
const state = new AppState(); const state = new AppState();
@ -30,8 +30,8 @@ const doRender = (Component: React.ComponentType) => {
doRender(App); doRender(App);
if (module.hot) { if (module.hot) {
module.hot.accept("@app/components/App", () => { module.hot.accept("@client/components/App", () => {
const NextApp = require<any>("@app/components/App").default as typeof App; const NextApp = require<any>("@client/components/App").default as typeof App;
doRender(NextApp); doRender(NextApp);
}); });
} }

4
app/pages/LoginPage.tsx → client/pages/LoginPage.tsx

@ -3,10 +3,10 @@ import { observer } from "mobx-react";
import * as React from "react"; import * as React from "react";
import { Container, Dimmer, Form, Header, InputOnChangeData, Loader, Message, Segment } from "semantic-ui-react"; import { Container, Dimmer, Form, Header, InputOnChangeData, Loader, Message, Segment } from "semantic-ui-react";
import { AppState, injectState } from "@app/state"; import { AppState, injectState } from "@client/state";
import log from "@common/logger"; import log from "@common/logger";
import "@app/styles/LoginPage"; import "@client/styles/LoginPage";
class LoginPageState { class LoginPageState {
@observable username = ""; @observable username = "";

2
app/pages/LogoutPage.tsx → client/pages/LogoutPage.tsx

@ -1,7 +1,7 @@
import * as React from "react"; import * as React from "react";
import { Redirect } from "react-router"; import { Redirect } from "react-router";
import { AppState, ConsumeState } from "@app/state"; import { AppState, ConsumeState } from "@client/state";
export function LogoutPage() { export function LogoutPage() {
function consumeState(appState: AppState) { function consumeState(appState: AppState) {

6
app/pages/ProgramPage.tsx → client/pages/ProgramPage.tsx

@ -5,9 +5,9 @@ import * as React from "react";
import { RouteComponentProps } from "react-router"; import { RouteComponentProps } from "react-router";
import { Button, CheckboxProps, Form, Icon, Input, InputOnChangeData, Menu, Modal } from "semantic-ui-react"; import { Button, CheckboxProps, Form, Icon, Input, InputOnChangeData, Menu, Modal } from "semantic-ui-react";
import { ProgramSequenceView, ScheduleView } from "@app/components"; import { ProgramSequenceView, ScheduleView } from "@client/components";
import * as rp from "@app/routePaths"; import * as rp from "@client/routePaths";
import { AppState, injectState } from "@app/state"; import { AppState, injectState } from "@client/state";
import log from "@common/logger"; import log from "@common/logger";
import { Program, SprinklersDevice } from "@common/sprinklersRpc"; import { Program, SprinklersDevice } from "@common/sprinklersRpc";

2
app/pages/index.tsx → client/pages/index.tsx

@ -1,7 +1,7 @@
import * as React from "react"; import * as React from "react";
import { RouteComponentProps } from "react-router"; import { RouteComponentProps } from "react-router";
import { DevicesView, MessageTest} from "@app/components"; import { DevicesView, MessageTest} from "@client/components";
export { LoginPage } from "./LoginPage"; export { LoginPage } from "./LoginPage";
export { LogoutPage } from "./LogoutPage"; export { LogoutPage } from "./LogoutPage";

0
app/polyfills.js → client/polyfills.js

0
app/routePaths.ts → client/routePaths.ts

2
app/sprinklersRpc/WebSocketRpcClient.ts → client/sprinklersRpc/WebSocketRpcClient.ts

@ -1,7 +1,7 @@
import { action, autorun, observable, when } from "mobx"; import { action, autorun, observable, when } from "mobx";
import { update } from "serializr"; import { update } from "serializr";
import { TokenStore } from "@app/state/TokenStore"; import { TokenStore } from "@client/state/TokenStore";
import { ErrorCode } from "@common/ErrorCode"; import { ErrorCode } from "@common/ErrorCode";
import * as rpc from "@common/jsonRpc"; import * as rpc from "@common/jsonRpc";
import logger from "@common/logger"; import logger from "@common/logger";

6
app/state/AppState.ts → client/state/AppState.ts

@ -2,9 +2,9 @@ import { createBrowserHistory, History } from "history";
import { computed } from "mobx"; import { computed } from "mobx";
import { RouterStore, syncHistoryWithStore } from "mobx-react-router"; import { RouterStore, syncHistoryWithStore } from "mobx-react-router";
import { WebSocketRpcClient } from "@app/sprinklersRpc/WebSocketRpcClient"; import { WebSocketRpcClient } from "@client/sprinklersRpc/WebSocketRpcClient";
import HttpApi from "@app/state/HttpApi"; import HttpApi from "@client/state/HttpApi";
import { UiStore } from "@app/state/UiStore"; import { UiStore } from "@client/state/UiStore";
import ApiError from "@common/ApiError"; import ApiError from "@common/ApiError";
import { ErrorCode } from "@common/ErrorCode"; import { ErrorCode } from "@common/ErrorCode";
import log from "@common/logger"; import log from "@common/logger";

2
app/state/HttpApi.ts → client/state/HttpApi.ts

@ -1,4 +1,4 @@
import { TokenStore } from "@app/state/TokenStore"; import { TokenStore } from "@client/state/TokenStore";
import ApiError from "@common/ApiError"; import ApiError from "@common/ApiError";
import { ErrorCode } from "@common/ErrorCode"; import { ErrorCode } from "@common/ErrorCode";

0
app/state/Token.ts → client/state/Token.ts

4
app/state/TokenStore.ts → client/state/TokenStore.ts

@ -1,7 +1,7 @@
import { observable } from "mobx"; import { observable } from "mobx";
import HttpApi, { ApiError } from "@app/state/HttpApi"; import HttpApi, { ApiError } from "@client/state/HttpApi";
import { Token } from "@app/state/Token"; import { Token } from "@client/state/Token";
import { TokenGrantPasswordRequest, TokenGrantRefreshRequest, TokenGrantResponse } from "@common/httpApi"; import { TokenGrantPasswordRequest, TokenGrantRefreshRequest, TokenGrantResponse } from "@common/httpApi";
import logger from "@common/logger"; import logger from "@common/logger";

0
app/state/UiStore.ts → client/state/UiStore.ts

0
app/state/index.ts → client/state/index.ts

2
app/state/reactContext.tsx → client/state/reactContext.tsx

@ -1,6 +1,6 @@
import * as React from "react"; import * as React from "react";
import { AppState } from "@app/state"; import { AppState } from "@client/state";
const StateContext = React.createContext<AppState | null>(null); const StateContext = React.createContext<AppState | null>(null);

0
app/styles/DeviceView.scss → client/styles/DeviceView.scss

0
app/styles/DurationView.scss → client/styles/DurationView.scss

0
app/styles/LoginPage.scss → client/styles/LoginPage.scss

0
app/styles/MessagesView.scss → client/styles/MessagesView.scss

0
app/styles/ProgramSequenceView.scss → client/styles/ProgramSequenceView.scss

0
app/styles/ScheduleView.scss → client/styles/ScheduleView.scss

0
app/styles/SectionChooser.scss → client/styles/SectionChooser.scss

0
app/styles/SectionRunnerView.scss → client/styles/SectionRunnerView.scss

0
app/styles/app.scss → client/styles/app.scss

4
app/tsconfig.json → client/tsconfig.json

@ -21,8 +21,8 @@
"@common/*": [ "@common/*": [
"./common/*" "./common/*"
], ],
"@app/*": [ "@client/*": [
"./app/*" "./client/*"
] ]
} }
} }

16
app/webpack.config.js → client/webpack.config.js

@ -111,7 +111,7 @@ const rules = (env) => {
// Process TypeScript with TSC through HappyPack. // Process TypeScript with TSC through HappyPack.
{ {
test: /\.tsx?$/, use: "happypack/loader?id=ts", test: /\.tsx?$/, use: "happypack/loader?id=ts",
include: [ paths.appDir, paths.commonDir ], include: [ paths.clientDir, paths.commonDir ],
}, },
// "file" loader makes sure those assets get served by WebpackDevServer. // "file" loader makes sure those assets get served by WebpackDevServer.
// When you `import` an asset, you get its (virtual) filename. // When you `import` an asset, you get its (virtual) filename.
@ -147,7 +147,7 @@ const getConfig = module.exports = (env) => {
const plugins = [ const plugins = [
new HtmlWebpackPlugin({ new HtmlWebpackPlugin({
inject: true, inject: true,
template: paths.appHtml, template: paths.clientHtml,
minify: isProd ? { minify: isProd ? {
removeComments: true, removeComments: true,
collapseWhitespace: true, collapseWhitespace: true,
@ -161,7 +161,7 @@ const getConfig = module.exports = (env) => {
minifyURLs: true, minifyURLs: true,
} : undefined, } : undefined,
}), }),
new FaviconsWebpackPlugin(path.resolve(paths.appDir, "images", "favicon-96x96.png")), new FaviconsWebpackPlugin(path.resolve(paths.clientDir, "images", "favicon-96x96.png")),
// Makes some environment variables available to the JS code, for example: // Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === "production") { ... }. See `./env.js`. // if (process.env.NODE_ENV === "production") { ... }. See `./env.js`.
// It is absolutely essential that NODE_ENV was set to production here. // It is absolutely essential that NODE_ENV was set to production here.
@ -179,14 +179,14 @@ const getConfig = module.exports = (env) => {
loaders: [{ loaders: [{
loader: "ts-loader", loader: "ts-loader",
options: { options: {
configFile: paths.appTsConfig, configFile: paths.clientTsConfig,
happyPackMode: true, happyPackMode: true,
}, },
}], }],
}), }),
new ForkTsCheckerWebpackPlugin({ new ForkTsCheckerWebpackPlugin({
checkSyntacticErrors: true, checkSyntacticErrors: true,
tsconfig: paths.appTsConfig, tsconfig: paths.clientTsConfig,
tslint: paths.resolveRoot("tslint.json"), tslint: paths.resolveRoot("tslint.json"),
}), }),
isDev && new DashboardPlugin(), isDev && new DashboardPlugin(),
@ -212,10 +212,10 @@ const getConfig = module.exports = (env) => {
isDev && require.resolve("react-hot-loader/patch"), isDev && require.resolve("react-hot-loader/patch"),
isDev && require.resolve("react-dev-utils/webpackHotDevClient"), isDev && require.resolve("react-dev-utils/webpackHotDevClient"),
require.resolve("./polyfills"), require.resolve("./polyfills"),
paths.appEntry, paths.clientEntry,
].filter(Boolean), ].filter(Boolean),
output: { output: {
path: paths.appBuildDir, path: paths.clientBuildDir,
pathinfo: isDev, pathinfo: isDev,
filename: isProd ? filename: isProd ?
'static/js/[name].[chunkhash:8].js' : 'static/js/[name].[chunkhash:8].js' :
@ -231,7 +231,7 @@ const getConfig = module.exports = (env) => {
resolve: { resolve: {
extensions: [".ts", ".tsx", ".js", ".json", ".scss"], extensions: [".ts", ".tsx", ".js", ".json", ".scss"],
alias: { alias: {
"@app": paths.appDir, "@client": paths.clientDir,
"@common": paths.commonDir, "@common": paths.commonDir,
} }
}, },

12
common/paths.js

@ -24,12 +24,12 @@ exports.publicPath = ensureSlash(url.parse(exports.publicUrl).pathname || "/", t
exports.commonDir = resolveRoot("common"); exports.commonDir = resolveRoot("common");
exports.appDir = resolveRoot("app"); exports.clientDir = resolveRoot("client");
exports.appEntry = path.resolve(exports.appDir, "index.tsx"); exports.clientEntry = path.resolve(exports.clientDir, "index.tsx");
exports.appHtml = path.resolve(exports.appDir, "index.html"); exports.clientHtml = path.resolve(exports.clientDir, "index.html");
exports.appWebpackConfig = path.resolve(exports.appDir, "webpack.config.js"); exports.clientWebpackConfig = path.resolve(exports.clientDir, "webpack.config.js");
exports.appTsConfig = path.resolve(exports.appDir, "tsconfig.json"); exports.clientTsConfig = path.resolve(exports.clientDir, "tsconfig.json");
exports.appBuildDir = resolveRoot("public"); exports.clientBuildDir = resolveRoot("public");
exports.publicDir = exports.appBuildDir; exports.publicDir = exports.appBuildDir;
exports.serverDir = resolveRoot("server"); exports.serverDir = resolveRoot("server");

4
common/tsconfig.json

@ -17,8 +17,8 @@
"@common/*": [ "@common/*": [
"./common/*" "./common/*"
], ],
"@app/*": [ "@client/*": [
"./app/*" "./client/*"
] ]
} }
}, },

2
docker-compose.dev.yml

@ -11,7 +11,7 @@ services:
- "8080:8080" - "8080:8080"
- "8081:8081" - "8081:8081"
volumes: volumes:
- ./app:/app/app - ./client:/app/client
- ./common:/app/common - ./common:/app/common
- ./server:/app/server - ./server:/app/server
env_file: env_file:

8
package.json

@ -6,18 +6,18 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"clean": "rm -rf ./dist ./build ./public", "clean": "rm -rf ./dist ./build ./public",
"build:app": "NODE_ENV=production webpack --config ./app/webpack.config.js --env prod", "build:client": "NODE_ENV=production webpack --config ./client/webpack.config.js --env prod",
"build:server": "tsc --project server", "build:server": "tsc --project server",
"build": "run-p build:*", "build": "run-p build:*",
"watch:app": "yarn build:app --watch", "watch:client": "yarn build:client --watch",
"watch:server": "yarn build:server --watch", "watch:server": "yarn build:server --watch",
"start:dev-server": "NODE_ENV=development webpack-dev-server --config ./app/webpack.config.js --env dev", "start:dev-server": "NODE_ENV=development webpack-dev-server --config ./client/webpack.config.js --env dev",
"start": "NODE_ENV=development node dist/server/index.js", "start": "NODE_ENV=development node dist/server/index.js",
"start:pretty": "yarn start | node dist/server/logging/prettyPrint.js", "start:pretty": "yarn start | node dist/server/logging/prettyPrint.js",
"start:nodemon": "nodemon --delay 0.5 --exec \"env NODE_ENV=development node dist/server/index.js | node dist/server/logging/prettyPrint.js\"", "start:nodemon": "nodemon --delay 0.5 --exec \"env NODE_ENV=development node dist/server/index.js | node dist/server/logging/prettyPrint.js\"",
"start:watch": "run-p watch:server start:nodemon", "start:watch": "run-p watch:server start:nodemon",
"start:dev": "run-p start:dev-server start:watch", "start:dev": "run-p start:dev-server start:watch",
"lint:app": "tslint --project app --force --format verbose", "lint:client": "tslint --project client --force --format verbose",
"lint:server": "tslint --project server --force --format verbose", "lint:server": "tslint --project server --force --format verbose",
"lint": "run-p lint:*" "lint": "run-p lint:*"
}, },

2
server/express/serveApp.ts

@ -7,7 +7,7 @@ import * as paths from "@common/paths";
const index = path.join(paths.publicDir, "index.html"); const index = path.join(paths.publicDir, "index.html");
export default function serveApp(app: Express) { export default function serveApp(app: Express) {
app.use(serveStatic(paths.appBuildDir)); app.use(serveStatic(paths.clientBuildDir));
app.get("/*", (req, res) => { app.get("/*", (req, res) => {
res.sendFile(index); res.sendFile(index);
}); });

4
server/tsconfig.json

@ -21,8 +21,8 @@
"@common/*": [ "@common/*": [
"./common/*" "./common/*"
], ],
"@app/*": [ "@client/*": [
"./app/*" "./client/*"
] ]
} }
}, },

Loading…
Cancel
Save