Updated imports, structure and webpack config stuff
This commit is contained in:
parent
18dbefbdb7
commit
cef5fb3ad5
@ -3,11 +3,11 @@ import DevTools from "mobx-react-devtools";
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Item } from "semantic-ui-react";
|
import { Item } from "semantic-ui-react";
|
||||||
|
|
||||||
import { UiStore } from "app/ui";
|
import { UiStore } from "@app/ui";
|
||||||
import { SprinklersDevice } from "common/sprinklers";
|
import { SprinklersDevice } from "@common/sprinklers";
|
||||||
import { DeviceView, MessagesView } from ".";
|
import { DeviceView, MessagesView } from ".";
|
||||||
|
|
||||||
import "app/style/app.css";
|
import "@app/styles/app.css";
|
||||||
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";
|
||||||
|
|
@ -5,7 +5,7 @@ import FontAwesome = require("react-fontawesome");
|
|||||||
import { Header, Item } from "semantic-ui-react";
|
import { Header, Item } from "semantic-ui-react";
|
||||||
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
|
import { ProgramTable, RunSectionForm, SectionRunnerView, SectionTable } from ".";
|
||||||
|
|
||||||
import { SprinklersDevice } from "common/sprinklers";
|
import { SprinklersDevice } from "@common/sprinklers";
|
||||||
|
|
||||||
const ConnectionState = ({ connected }: { connected: boolean }) => {
|
const ConnectionState = ({ connected }: { connected: boolean }) => {
|
||||||
const classes = classNames({
|
const classes = classNames({
|
||||||
@ -27,7 +27,7 @@ export default class DeviceView extends React.Component<{ device: SprinklersDevi
|
|||||||
const { id, connected, sections, programs, sectionRunner } = this.props.device;
|
const { id, connected, sections, programs, sectionRunner } = this.props.device;
|
||||||
return (
|
return (
|
||||||
<Item>
|
<Item>
|
||||||
<Item.Image src={require<string>("app/images/raspberry_pi.png")} />
|
<Item.Image src={require<string>("@app/images/raspberry_pi.png")} />
|
||||||
<Item.Content>
|
<Item.Content>
|
||||||
<Header as="h1">
|
<Header as="h1">
|
||||||
<span>Device </span><kbd>{id}</kbd>
|
<span>Device </span><kbd>{id}</kbd>
|
@ -1,7 +1,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Input, InputOnChangeData } from "semantic-ui-react";
|
import { Input, InputOnChangeData } from "semantic-ui-react";
|
||||||
|
|
||||||
import { Duration } from "common/sprinklers";
|
import { Duration } from "@common/sprinklers";
|
||||||
|
|
||||||
export default class DurationInput extends React.Component<{
|
export default class DurationInput extends React.Component<{
|
||||||
duration: Duration,
|
duration: Duration,
|
@ -2,7 +2,7 @@ import { observer } from "mobx-react";
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Message, MessageList, TransitionGroup } from "semantic-ui-react";
|
import { Message, MessageList, TransitionGroup } from "semantic-ui-react";
|
||||||
|
|
||||||
import { Message as UiMessage, UiStore } from "app/ui";
|
import { Message as UiMessage, UiStore } from "@app/ui";
|
||||||
|
|
||||||
class MessageView extends React.Component<{
|
class MessageView extends React.Component<{
|
||||||
uiStore: UiStore,
|
uiStore: UiStore,
|
@ -2,7 +2,7 @@ import { observer } from "mobx-react";
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { Table } from "semantic-ui-react";
|
import { Table } from "semantic-ui-react";
|
||||||
|
|
||||||
import { Program, Schedule } from "common/sprinklers";
|
import { Program, Schedule } from "@common/sprinklers";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export class ScheduleView extends React.Component<{ schedule: Schedule }> {
|
export class ScheduleView extends React.Component<{ schedule: Schedule }> {
|
@ -1,10 +1,10 @@
|
|||||||
import {computed} from "mobx";
|
import { computed } from "mobx";
|
||||||
import {observer} from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import {DropdownItemProps, DropdownProps, Form, Header, Segment} from "semantic-ui-react";
|
import { DropdownItemProps, DropdownProps, Form, Header, Segment } from "semantic-ui-react";
|
||||||
|
|
||||||
import {Duration, Section} from "common/sprinklers";
|
import { Duration, Section } from "@common/sprinklers";
|
||||||
import {DurationInput} from ".";
|
import DurationInput from "./DurationInput";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export default class RunSectionForm extends React.Component<{
|
export default class RunSectionForm extends React.Component<{
|
||||||
@ -22,14 +22,14 @@ export default class RunSectionForm extends React.Component<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {section, duration} = this.state;
|
const { section, duration } = this.state;
|
||||||
return <Segment>
|
return <Segment>
|
||||||
<Header>Run Section</Header>
|
<Header>Run Section</Header>
|
||||||
<Form>
|
<Form>
|
||||||
<Form.Group>
|
<Form.Group>
|
||||||
<Form.Select label="Section" placeholder="Section" options={this.sectionOptions} value={section}
|
<Form.Select label="Section" placeholder="Section" options={this.sectionOptions} value={section}
|
||||||
onChange={this.onSectionChange}/>
|
onChange={this.onSectionChange} />
|
||||||
<DurationInput duration={duration} onDurationChange={this.onDurationChange}/>
|
<DurationInput duration={duration} onDurationChange={this.onDurationChange} />
|
||||||
{/*Label must be to align it properly*/}
|
{/*Label must be to align it properly*/}
|
||||||
<Form.Button label=" " primary onClick={this.run} disabled={!this.isValid}>Run</Form.Button>
|
<Form.Button label=" " primary onClick={this.run} disabled={!this.isValid}>Run</Form.Button>
|
||||||
</Form.Group>
|
</Form.Group>
|
||||||
@ -38,11 +38,11 @@ export default class RunSectionForm extends React.Component<{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onSectionChange = (e: React.SyntheticEvent<HTMLElement>, v: DropdownProps) => {
|
private onSectionChange = (e: React.SyntheticEvent<HTMLElement>, v: DropdownProps) => {
|
||||||
this.setState({section: v.value as number});
|
this.setState({ section: v.value as number });
|
||||||
}
|
}
|
||||||
|
|
||||||
private onDurationChange = (newDuration: Duration) => {
|
private onDurationChange = (newDuration: Duration) => {
|
||||||
this.setState({duration: newDuration});
|
this.setState({ duration: newDuration });
|
||||||
}
|
}
|
||||||
|
|
||||||
private run = (e: React.SyntheticEvent<HTMLElement>) => {
|
private run = (e: React.SyntheticEvent<HTMLElement>) => {
|
@ -1,8 +1,8 @@
|
|||||||
import {observer} from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import {Segment} from "semantic-ui-react";
|
import { Segment } from "semantic-ui-react";
|
||||||
|
|
||||||
import {SectionRunner} from "common/sprinklers";
|
import { SectionRunner } from "@common/sprinklers";
|
||||||
|
|
||||||
@observer
|
@observer
|
||||||
export default class SectionRunnerView extends React.Component<{ sectionRunner: SectionRunner }, {}> {
|
export default class SectionRunnerView extends React.Component<{ sectionRunner: SectionRunner }, {}> {
|
@ -4,7 +4,7 @@ import * as React from "react";
|
|||||||
import FontAwesome = require("react-fontawesome");
|
import FontAwesome = require("react-fontawesome");
|
||||||
import { Table } from "semantic-ui-react";
|
import { Table } from "semantic-ui-react";
|
||||||
|
|
||||||
import { Section } from "common/sprinklers";
|
import { Section } from "@common/sprinklers";
|
||||||
|
|
||||||
/* tslint:disable:object-literal-sort-keys */
|
/* tslint:disable:object-literal-sort-keys */
|
||||||
|
|
@ -2,9 +2,9 @@ import * as React from "react";
|
|||||||
import * as ReactDOM from "react-dom";
|
import * as ReactDOM from "react-dom";
|
||||||
import { AppContainer } from "react-hot-loader";
|
import { AppContainer } from "react-hot-loader";
|
||||||
|
|
||||||
import App from "./components/App";
|
import App from "@app/components/App";
|
||||||
import { MqttApiClient } from "./mqtt";
|
import { MqttApiClient } from "@app/mqtt";
|
||||||
import { Message, UiStore } from "./ui";
|
import { Message, UiStore } from "@app/ui";
|
||||||
|
|
||||||
const client = new MqttApiClient();
|
const client = new MqttApiClient();
|
||||||
client.start();
|
client.start();
|
||||||
@ -25,8 +25,8 @@ const doRender = (Component: typeof App) => {
|
|||||||
doRender(App);
|
doRender(App);
|
||||||
|
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
module.hot.accept("app/components/App", () => {
|
module.hot.accept("@app/components/App", () => {
|
||||||
const NextApp = require<any>("app/components/App").default as typeof App;
|
const NextApp = require<any>("@app/components/App").default as typeof App;
|
||||||
doRender(NextApp);
|
doRender(NextApp);
|
||||||
});
|
});
|
||||||
}
|
}
|
@ -13,8 +13,8 @@ import {
|
|||||||
SectionRunner,
|
SectionRunner,
|
||||||
SprinklersDevice,
|
SprinklersDevice,
|
||||||
TimeOfDay,
|
TimeOfDay,
|
||||||
} from "common/sprinklers";
|
} from "@common/sprinklers";
|
||||||
import { checkedIndexOf, getRandomId } from "common/utils";
|
import { checkedIndexOf, getRandomId } from "@common/utils";
|
||||||
|
|
||||||
export class MqttApiClient implements ISprinklersApi {
|
export class MqttApiClient implements ISprinklersApi {
|
||||||
client: MQTT.Client;
|
client: MQTT.Client;
|
@ -5,16 +5,16 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"lib": ["es6", "dom"],
|
"lib": ["es6", "dom"],
|
||||||
"typeRoots": ["node_modules/@types"],
|
// "typeRoots": ["node_modules/@types"],
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"baseUrl": "..",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"common/*": [ "../common/*" ],
|
"@common/*": [ "../common/*" ],
|
||||||
"app/*": [ "./*" ]
|
"@app/*": [ "./*" ]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"./node_modules/@types/webpack-env/index.d.ts",
|
"../node_modules/@types/webpack-env/index.d.ts",
|
||||||
"./app/script/index.tsx"
|
"./app/script/index.tsx"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {observable} from "mobx";
|
import {observable} from "mobx";
|
||||||
|
|
||||||
import { getRandomId } from "common/utils";
|
import { getRandomId } from "@common/utils";
|
||||||
|
|
||||||
export class Message {
|
export class Message {
|
||||||
id: string;
|
id: string;
|
@ -2,27 +2,32 @@ const path = require("path");
|
|||||||
const webpack = require("webpack");
|
const webpack = require("webpack");
|
||||||
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
||||||
|
|
||||||
|
const rootDir = path.resolve(__dirname, "..");
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
devtool: "eval-source-map",
|
entry: [
|
||||||
|
"core-js",
|
||||||
|
"./app/index.tsx"
|
||||||
|
],
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "..", "build"),
|
path: path.resolve(rootDir, "build"),
|
||||||
filename: "bundle.js"
|
filename: "bundle.js"
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: [".ts", ".tsx", ".js"],
|
extensions: [".ts", ".tsx", ".js", ".json"],
|
||||||
alias: {
|
alias: {
|
||||||
app: path.resolve(__dirname, "..", "app"),
|
"@app": path.resolve(rootDir, "app"),
|
||||||
common: path.resolve(__dirname, "..", "common"),
|
"@common": path.resolve(rootDir, "common"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
module: {
|
module: {
|
||||||
rules: [
|
rules: [
|
||||||
{ test: /\.css$/, use: "style-loader!css-loader" },
|
{ test: /\.css$/, use: ["style-loader", "css-loader"] },
|
||||||
{ test: /\.(ttf|eot|svg|woff(2)?|png|jpg)(\?[a-z0-9=&.]+)?$/, use: "file-loader" },
|
{ test: /\.(ttf|eot|svg|woff(2)?|png|jpg)(\?[a-z0-9=&.]+)?$/, use: "file-loader" },
|
||||||
{
|
{
|
||||||
test: /\.tsx?$/, use: {
|
test: /\.tsx?$/, use: {
|
||||||
loader: "awesome-typescript-loader",
|
loader: "awesome-typescript-loader",
|
||||||
options: { configFileName: path.resolve(__dirname, "..", "app", "tsconfig.json") }
|
options: { configFileName: path.resolve(rootDir, "app", "tsconfig.json") }
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -32,9 +37,5 @@ module.exports = {
|
|||||||
template: "./app/index.html"
|
template: "./app/index.html"
|
||||||
}),
|
}),
|
||||||
new webpack.NamedModulesPlugin(),
|
new webpack.NamedModulesPlugin(),
|
||||||
new webpack.HotModuleReplacementPlugin()
|
|
||||||
],
|
],
|
||||||
devServer: {
|
|
||||||
hot: true
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
@ -2,18 +2,17 @@ const webpack = require("webpack");
|
|||||||
const webpackMerge = require("webpack-merge");
|
const webpackMerge = require("webpack-merge");
|
||||||
const base = require("./base.config");
|
const base = require("./base.config");
|
||||||
|
|
||||||
module.exports = webpackMerge.smart(base, {
|
module.exports = webpackMerge.strategy({
|
||||||
|
entry: "prepend",
|
||||||
|
})(base, {
|
||||||
|
devtool: "eval-source-map",
|
||||||
entry: [
|
entry: [
|
||||||
"react-hot-loader/patch",
|
"react-hot-loader/patch",
|
||||||
"webpack-dev-server/client?http://localhost:8080",
|
"webpack-dev-server/client?http://localhost:8080",
|
||||||
"webpack/hot/only-dev-server",
|
"webpack/hot/only-dev-server",
|
||||||
"core-js",
|
|
||||||
"./app/script/index.tsx"
|
|
||||||
],
|
],
|
||||||
devtool: "eval-source-map",
|
|
||||||
plugins: [
|
plugins: [
|
||||||
new webpack.NamedModulesPlugin(),
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
// new webpack.HotModuleReplacementPlugin(),
|
|
||||||
],
|
],
|
||||||
devServer: {
|
devServer: {
|
||||||
hot: true
|
hot: true
|
||||||
|
@ -1,12 +1,7 @@
|
|||||||
const webpackMerge = require("webpack-merge");
|
const webpackMerge = require("webpack-merge");
|
||||||
const base = require("./base.config");
|
const base = require("./base.config");
|
||||||
|
|
||||||
module.exports = webpackMerge.smart(base, {
|
module.exports = webpackMerge.strategy({})(base, {
|
||||||
entry: [
|
|
||||||
"core-js",
|
|
||||||
"./app/script/index.tsx"
|
|
||||||
],
|
|
||||||
devtool: "none",
|
devtool: "none",
|
||||||
plugins: [
|
plugins: []
|
||||||
]
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user