diff --git a/Procfile b/Procfile index c86110a5184f..c55545f845cc 100644 --- a/Procfile +++ b/Procfile @@ -1,8 +1,7 @@ # Run Rails & Webpack concurrently # If you wish to use a different server then the default, use e.g. `export RAILS_STARTUP='puma -w 3 -p 3000 --preload'` rails: [ -n "$RAILS_STARTUP" ] && env PRY_WARNING=1 $RAILS_STARTUP || [ -n "$BIND" ] && bin/rails server -b $BIND || env PRY_WARNING=1 bin/rails server -# you can use WEBPACK_OPTS to customize webpack server, e.g. 'WEBPACK_OPTS='--https --key /path/to/key --cert /path/to/cert.pem --cacert /path/to/cacert.pem' foreman start ' -webpack: [ -n "$NODE_ENV" ] && npx webpack --config config/webpack.config.js --watch $WEBPACK_OPTS || env NODE_ENV=development npx webpack --config config/webpack.config.js --watch -#TODO readme/forklift to change/remove --key to --server-options-key -# --public -> --client-web-socket-url and see why it doesnt work -# --https --> --server-type + +# you can use WEBPACK_OPTS to customize webpack server, e.g. 'WEBPACK_OPTS=--analyze' foreman start ' +# filter out webpack options that are commonly used but not supported by webpack 5 and not needed in the new configutation as webpack is not run as a server anymore +webpack: FILTERED_WEBPACK_OPTS=$(echo $WEBPACK_OPTS | sed -e 's/--key [^ ]*//g' -e 's/--public [^ ]*//g' -e 's/--https [^ ]*//g' -e 's/--cert [^ ]*//g' -e 's/--cacert [^ ]*//g') && [ -n "$NODE_ENV" ] && npx webpack --config config/webpack.config.js --watch $FILTERED_WEBPACK_OPTS || env NODE_ENV=development npx webpack --config config/webpack.config.js --watch $FILTERED_WEBPACK_OPTS \ No newline at end of file diff --git a/developer_docs/getting-started.asciidoc b/developer_docs/getting-started.asciidoc index f1e1e68cd773..11f96546f1da 100644 --- a/developer_docs/getting-started.asciidoc +++ b/developer_docs/getting-started.asciidoc @@ -25,14 +25,12 @@ Following steps are required to setup a webpack development environment: ``` 3. **Additional config** - Both `foreman start` and `foreman-start-dev` support `WEBPACK_OPTS` environment variable for passing additional options. This is handy for example when you have development setup with Katello and want to use correct certificates. + Both `foreman start` and `foreman-start-dev` support `WEBPACK_OPTS` environment variable for passing additional options. The webpack build is done for Foreman core and plugins at the same time but seperatly, so options like `--anaylze` that start a server for each build will not work. An example of such setup: + [source,bash] ---- - npx webpack \ - --config config/webpack.config.js \ - --watchOptions-poll 1000 # only use for NFS https://community.theforeman.org/t/webpack-watch-over-nfs/10922 + WEBPACK_OPTS='--progress' foreman start webpack ---- + Additionally you can set `NOTIFICATIONS_POLLING` variable to extend the notification polling interval that is 10s by default and can clutter the console. diff --git a/script/foreman-start-dev b/script/foreman-start-dev index a93987326d71..655fcd2c64b9 100755 --- a/script/foreman-start-dev +++ b/script/foreman-start-dev @@ -1,3 +1,3 @@ #!/bin/sh -npx webpack --config config/webpack.config.js --watch $WEBPACK_OPTS & +FILTERED_WEBPACK_OPTS=$(echo $WEBPACK_OPTS | sed -e 's/--key [^ ]*//g' -e 's/--public [^ ]*//g' -e 's/--https [^ ]*//g' -e 's/--cert [^ ]*//g' -e 's/--cacert [^ ]*//g') && npx webpack --config config/webpack.config.js --watch $FILTERED_WEBPACK_OPTS & ./bin/rails server -b \[::\] "$@"