forked from Graylog2/graylog2-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web dev improvements (Graylog2#4388)
* Customize port number in dev-server Let users customize port number by passing `--port=<port>` as argument. If the port is already taken, we will start the web interface in a random one. * Remove alternative dev setup * Revert dev server port Changed it accidentally during some tests. * Remove react-hot-loader dev build The `start` build using HMR alongside react-hot-loader was already not working as it should with webpack-dev-server. Modules got reloaded, but the application state was reset on every change. I have been trying a couple of times to make HMR work with the new express dev server, but I just managed to reproduce what it achieved in the previous build (reloading the whole component tree, but losing the state). All of that making the current webpack configuration more complicated. I think react-hot-loader is a good idea that can be helpful specially when styling components, but currently I see that it produces way too maintenance burden for the benefits it provides. Also, nobody in the team seems to be using it for development. Long story short, this commit removes react-hot-loader from our dev build. We still use Webpack HMR to reload the browser. The commit also replaces the `start` script with `start-nohmr`, so running `yarn start` will use the no react-hot-loader dev server. * Update README file - Include details to use yarn in development - Remove old warnings and information - Remove mentions of the react-hot-loader build - Update information on upgrade packages - Update information on IntelliJ setup * Improve some texts in the README * Add documentation on how to customize port number * Fix linter errors
- Loading branch information
Showing
9 changed files
with
71 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"presets": ["es2015", "react", "stage-0"], | ||
"plugins": ["add-module-exports", "react-hot-loader/babel"] | ||
"plugins": ["add-module-exports"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,37 @@ | ||
# Graylog Web Interface | ||
|
||
## Development Setup | ||
|
||
* Install [node.js](http://nodejs.org/) and npm. | ||
* Run `npm install` | ||
* Run `npm start` (if you don't want to include plugins in the build while developing, simply run `disable_plugins=true npm start`) | ||
* Open http://localhost:8080 | ||
|
||
The `npm start` (or `disable_plugins=true npm start`) command will run the `webpack-dev-server`, which allows in-browser hot reloading. | ||
In order to make switching between different branches faster, we use a script to store all `node_modules` folders | ||
into `.node_cache` and then symlink the folder for the current branch to `node_modules`. | ||
## Requirements | ||
- [Node.js](https://nodejs.org/), at this time we use v8.9.1 | ||
- [Yarn](https://yarnpkg.com/) | ||
|
||
When using IntelliJ or WebStorm, be sure to enable `JSX harmony` (available in IntelliJ 14 and WebStorm 9) | ||
as JavaScript language version to properly support react templates. | ||
**Note:** NPM v5 changed completely the way it builds local modules, breaking the Graylog web interface build. Please use Yarn instead of NPM v5. | ||
|
||
You might get an error message during `npm install` from `gyp` because the installed (default) Python version is too recent (sic!): | ||
|
||
``` | ||
gyp ERR! stack Error: Python executable "python" is v3.4.2, which is not supported by gyp. | ||
``` | ||
|
||
In this case just set the correct (installed!) Python binary before running `npm install`: | ||
## Development Setup | ||
|
||
``` | ||
npm config set python python2.7 | ||
``` | ||
* Install the requirements listed above | ||
* Run `yarn install` | ||
* Run `yarn start` to build the project for development and start the development server. You can exclude any Graylog frontend plugins from the build by running `disable_plugins=true npm start` instead | ||
* Open http://localhost:8080 in your browser to access the Graylog web interface | ||
|
||
### Alternative Development Setup | ||
The `yarn start` (or `disable_plugins=true yarn start`) command will run an [Express](http://expressjs.com) web server which is configured to do a full page reload in your browser every time that you save a file. This ensures that you will always use the latest version of your code. | ||
|
||
Due to problems with webpack-dev-server there is another way to run the development setup. | ||
You can start the development server in any other port that you like. To do so, use the `--port=<port>` option, e.g. `yarn start --port=8000` will start the development server in port 8000 instead of the default 8080. The server will also pick a random port if the port is already taken, so you don't need to worry if another process is already using that port. | ||
|
||
* Install [devd](https://github.com/cortesi/devd) | ||
* Install [node.js](http://nodejs.org/) and npm. | ||
* Run `npm install` | ||
* Run `npm run watch` and **keep it running** to start webpack in watch mode so it rebuilds on source changes | ||
* Run `npm run devd` and **keep it running** once the `build/` directory exists | ||
* Open http://localhost:8080 | ||
We mainly develop using IntelliJ or WebStorm. If you also decide to use them to work in Graylog, enable `React JSX` as Javascript language version to support the JSX language extension. This setting was called `JSX harmony` before, and it is available in one or the other form since IntelliJ 14 and WebStorm 9. | ||
|
||
## Update Javascript dependencies | ||
|
||
#### Update Javascript dependencies | ||
1. Update a single dependency | ||
|
||
a. Update a single dependency | ||
* Run `yarn upgrade <package>@<version>` | ||
* Commit any changes in both `package.json` and `yarn.lock` files | ||
* Do any changes required to adapt the code to the upgraded modules | ||
|
||
* Update `package.json` file with the new dependency | ||
* `npm update <npm-package>` | ||
* `npm shrinkwrap --dev` to save the whole dependency tree into the `npm-shrinkwrap.json` file | ||
1. Update many dependencies | ||
|
||
b. Update devDependencies | ||
* It may be dangerous updating many dependencies at the same time, so be sure you checked the upgrade notes of all modules before getting started. Once you are ready to upgrade the modules, Yarn provides a few options to do it: | ||
* You can pass all packages you want to upgrade to Yarn: `yarn upgrade <package1> <package2>...` | ||
* Yarn also supports upgrading packages matching a pattern, so you can execute `yarn upgrade --pattern <pattern>` | ||
* You could execute `yarn upgrade` if you really want to upgrade all packages | ||
* After doing the upgrade, remember to commit both the `package.json` and `yarn.lock` files | ||
|
||
* `npm shinkwrap` to keep the dependency tree (without devDependencies) into `npm-shrinkwrap.json` | ||
* Update `package.json` file with the new devDependencies | ||
* `npm install` | ||
* Do more work with the new devDependencies | ||
* `npm shrinkwrap --dev` to export the whole dependency tree with the new devDependencies into `npm-shrinkwrap.json` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.