Coder Social home page Coder Social logo

How to run a dev server about leviathan HOT 13 CLOSED

thoragio avatar thoragio commented on September 1, 2024
How to run a dev server

from leviathan.

Comments (13)

BenoitZugmeyer avatar BenoitZugmeyer commented on September 1, 2024 2

I commited a new bin/build implementation in full nodejs, hopefully solving your issues.

Just run npm run dev and it will:

  • build
  • serve on port 10001
  • watch for change and rebuild + reload

from leviathan.

BenoitZugmeyer avatar BenoitZugmeyer commented on September 1, 2024 2

Ah, no problem! FYI I finally use Webpack (but with Rollup behind) to simplify and standardize the build process and dev tools. Watching files is not ideal right now, but I made a PR to rollup-loader to improve this, cf egoist/rollup-loader#11

from leviathan.

thoragio avatar thoragio commented on September 1, 2024 1

I figured out that I needed to run the /bin/dev-server script with node. I installed node 7.9.0 since the async function was not working with v6 of node. So when I run node bin/devserver I get the following error:

Temporary directory: /Users/thoragio/code/leviathan/tmp-leviathan-bY9ntU
Listen: localhost:8080
Upstreams:
  /	/Users/thoragio/code/leviathan/

Generating certificates...
Launching HTTP server (use ^C to quit)...
events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: spawn nginx ENOENT
    at exports._errnoException (util.js:1050:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)

I'm guessing I need to install nginx on my machine. I'll try that next when I have some more time later today.

from leviathan.

theChesCat avatar theChesCat commented on September 1, 2024 1

Thanks a lot for taking the time to post your code @thoragio !
Clever thing to directly set the path for the new openssl version in the /bin/build file, I'm on OS X too so I was facing the same issue.

from leviathan.

BenoitZugmeyer avatar BenoitZugmeyer commented on September 1, 2024 1

Rollup really needs stuff like webpack-dev-server and html-webpack-plugin :D

from leviathan.

theChesCat avatar theChesCat commented on September 1, 2024

Asking myself the same question as @thoragio

from leviathan.

BenoitZugmeyer avatar BenoitZugmeyer commented on September 1, 2024

Hi, thank you for your interest! Please know that this project is just a start and you can't do much with it right now.

I should remove the bin/dev-server script as it isn't needed: just serve the dist server with any commandline dev server and it should work:

  • with python 2 : cd dist && python2 -m SimpleHTTPServer
  • with python 3 : cd dist && python -m http.server
  • with php : cd dist && php -S localhost:8000
  • if you want to stick with nodejs, you can use http-server (npm install http-server)

Also if you want to rebuild things when developping, you can watch for changes with $(npm bin)/rollup -c -w

from leviathan.

thoragio avatar thoragio commented on September 1, 2024

Thanks @BenoitZugmeyer. Running it with live-server (node) works great.

@theChesCat Here's what my bin/build file looks like now:

#!/bin/bash

set -euo pipefail

BIN="$(npm bin)"

cd $(dirname $0)/..
rm -rf dist
mkdir dist

cp -r assets/* dist

"$BIN"/rollup -c
"$BIN"/babili dist/index.js -o dist/index.js
hash=$(/usr/local/opt/openssl/bin/openssl sha256 dist/index.js | tail -c 65)
sed -i -e "s/BUNDLE_NAME/index.js?$hash/" dist/index.html
"$BIN"/rollup -c -w

And here's how it diffs from the original:

-hash=$(openssl sha256 dist/index.js | tail -c 65)
-sed -i "s/BUNDLE_NAME/index.js?$hash/" dist/index.html
+hash=$(/usr/local/opt/openssl/bin/openssl sha256 dist/index.js | tail -c 65)
+sed -i -e "s/BUNDLE_NAME/index.js?$hash/" dist/index.html
+"$BIN"/rollup -c -w

Note that the full path for openssl is a bit of a hack on my side because I don't want to rewrite the path for everything in case it breaks anything else relying on the older version of openssl that is still installed by default in OS X.

from leviathan.

theChesCat avatar theChesCat commented on September 1, 2024

Thanks a lot!

from leviathan.

thoragio avatar thoragio commented on September 1, 2024

Thank you. Much appreciated.

from leviathan.

theChesCat avatar theChesCat commented on September 1, 2024

(Or you need to use Webpack :trollface: )

from leviathan.

thoragio avatar thoragio commented on September 1, 2024

@BenoitZugmeyer Thanks for the tutorial with 3 examples today. I think you thoroughly answered my original question which was the title of this issue: how to run a dev server! 🙌

from leviathan.

thoragio avatar thoragio commented on September 1, 2024

Awesome! It's already been merged earlier this morning. 💨

from leviathan.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.