diff --git a/README.md b/README.md index f0a0403..4672657 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,17 @@ -# Space Map +# MQTT Control Map -## How to set up +## Development / Configuration 1. run `yarn` to install all dependencies. -2. run `yarn build` to compile everything -3. open the `index.html` -4. ??? -5. profit +2. run `yarn watch CONFIG` to run a local build server that automatically builds +your the mqtt control map for the given CONFIG everytime something changes. +3. run `yarn build CONFIG` to create just a single build of the mqtt control map +for the given config. +4. run `yarn production-build CONFIG` to generate all files for production use. ## Config -See `src/config.js`. +See `config/`. The Config format consists out of two sections. Topics and Controls. diff --git a/config/entropia.js b/config/entropia.js index 14691a3..233b390 100644 --- a/config/entropia.js +++ b/config/entropia.js @@ -60,4 +60,4 @@ const config : Config = { ] }; -export default config; +window.config = config; diff --git a/config/rzl.js b/config/rzl.js index b9b5b9b..a85c63e 100644 --- a/config/rzl.js +++ b/config/rzl.js @@ -533,4 +533,4 @@ const config : Config = { ] }; -export default config; +window.config = config; diff --git a/package.json b/package.json index bcf96bb..992b444 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,9 @@ "author": "uwap ", "description": "control devices via mqtt on a beautiful map of your space", "scripts": { - "build": "webpack --bail --config webpack.dev.js", - "production-build": "webpack --bail --config webpack.prod.js", - "watch": "webpack-dev-server --open --config webpack.dev.js", + "build": "webpack --bail --config webpack.dev.js --env", + "production-build": "webpack --bail --config webpack.prod.js --env", + "watch": "webpack-dev-server --open --config webpack.dev.js --env", "travis": "yarn lint && yarn build && yarn production-build", "lint": "eslint -- --ext js --ext jsx src/", "precommit": "yarn lint" diff --git a/src/config.js b/src/config.js deleted file mode 100644 index 96cf77e..0000000 --- a/src/config.js +++ /dev/null @@ -1,4 +0,0 @@ -// @flow -import config from "../config/entropia"; - -export default config; diff --git a/src/index.jsx b/src/index.jsx index f115191..82c04cd 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -5,11 +5,10 @@ import injectTapEventPlugin from "react-tap-event-plugin"; import App from "components/App"; -import Config from "./config"; - import "../node_modules/mdi/css/materialdesignicons.min.css"; import "../css/styles.css"; +const Config = window.config; injectTapEventPlugin(); document.title = `${Config.space.name} Map`; diff --git a/webpack.dev.js b/webpack.dev.js index 5e4914c..fb70be8 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -10,9 +10,17 @@ const extractCSS = ExtractTextPlugin.extract({ } }); -module.exports = merge(common, { +const configPath = env => { + if (env === true) { + throw "No config file was provided."; + } + return path.resolve(__dirname, `config/${env}`); +}; + +module.exports = env => merge(common, { entry: { - main: path.resolve(__dirname, 'src/index.jsx') + main: [configPath(env), + path.resolve(__dirname, 'src/index.jsx')] }, module: { loaders: [ diff --git a/webpack.prod.js b/webpack.prod.js index 22c30b3..e0f5155 100644 --- a/webpack.prod.js +++ b/webpack.prod.js @@ -15,9 +15,17 @@ const extractCSS = ExtractTextPlugin.extract({ } }); -module.exports = merge(common, { +const configPath = env => { + if (env === true) { + throw "No config file was provided."; + } + return path.resolve(__dirname, `config/${env}`); +}; + +module.exports = env => merge(common, { entry: { - main: path.resolve(__dirname, 'src/index.jsx'), + main: [configPath(env), + path.resolve(__dirname, 'src/index.jsx')] vendor: ['react', 'material-ui', 'mqtt', 'lodash'] }, module: {