RickWong / wait-run

Wait for a file or directory to change or appear, then run a command once.
16 stars 8 forks source link

Subshell environment #2

Closed chemoish closed 8 years ago

chemoish commented 8 years ago

So I am continually exploring the SSR/CSS stuff we spoke about before and it finally has lead me to this…

wait-run --pattern "build/index.js" "(cd build && node index)"

This doesn't work with wait-run, but do you know if its possible to execute subshells within your setup?


Additional information:

The location you execute node determines your static paths, relatively. This ends up effecting webpack's publicPath configuration.

However, if you run concurrently --kill-others "npm run watch-server" "npm run watch-client"—manually wait—then run the command above, it works.

RickWong commented 8 years ago

You should try just-wait. It's more flexible.

chemoish commented 8 years ago

Works thanks!

"scripts": {
  "start": "node ./node_modules/concurrently/src/main --kill-others \"npm run watch-server\" \"npm run watch-client\" \"npm run start-server\"",
  "build-client": "node ./node_modules/webpack/bin/webpack --config webpack/webpack.config.client-build",
  "build-server": "node ./node_modules/webpack/bin/webpack --config webpack/webpack.config.server-build",
  "start-server": "node ./node_modules/just-wait/bin/just-wait --pattern \"build/index.js\" && (cd build && node ./index)",
  "watch-client": "node ./node_modules/webpack-dev-server/bin/webpack-dev-server --config webpack/webpack.config.client-start",
  "watch-server": "rm -rf build && node ./node_modules/webpack/bin/webpack --colors --config webpack/webpack.config.server-start",
  "test": "karma start --single-run"
}
  1. server runs on localhost:8080 output to build folder
  2. client runs on localhost:8081 output to build/static
  3. server css is delivered from build/index.css
  4. server fonts is delivered from build/*.ttf
  5. prod follows same structure as development