Skip to content
Permalink
Browse files

Added ‘parcel’ to the build process

  • Loading branch information...
Giulio Cesare Solaroli
Giulio Cesare Solaroli committed Apr 30, 2019
1 parent 49c8304 commit 7c4ce7bb53932395ef8e092ad4312aec0d7782c4
Showing with 16 additions and 52 deletions.
  1. +1 −9 .gitignore
  2. +8 −2 README.md
  3. +6 −16 modd.conf
  4. +1 −25 src/purescript/Components/Random.purs
@@ -1,11 +1,3 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*
/.spago
/target
/.cache
@@ -5,14 +5,20 @@ Compiling the [`purescript`](http://www.purescript.org) code, supposing [`nvm`](
> nvm install --lts
> npm install -g purescript
> npm install -g spago
> npm install -g parcel-bundler
> spago install --jobs 10
> spago bundle --to target/js/index.js

In order to run the full project you need a few extra tools:

- [`modd`](https://github.com/cortesi/modd)
- [`devd`](https://github.com/cortesi/devd)
- [`sass`](https://sass-lang.com/install)

With these tools installed, you can just run the `modd` command from inside the project folder, and the application will be available at this local (127.0.0.1) url: [`http://devd.io:8000`](http://devd.io:8000/)
With these tools installed, you can just run the `modd` command from inside the project folder, and the application will be available at running on a local port, reported by [`ParcelJS`]() logs:

>> starting...
Server running at http://localhost:1234
✨ Built in 2.36s.

@@ -1,5 +1,5 @@
{
prep: rm -rf ./target
prep: rm -rf ./output
}

spago.dhall {
@@ -9,30 +9,20 @@ spago.dhall {

src/purescript/**/*.purs {
prep: echo "Purescript - changed files: " @mods
prep: spago bundle --to target/js/index.js
# prep: spago bundle --to ./.target/js/index.js -- --output ./.target/.output --codegen js,sourcemaps --verbose-errors
prep: spago bundle --to ./output/.target/js/index.js -- --output ./output --codegen js,sourcemaps --verbose-errors
}

src/html/**/*.html {
prep: echo "HTML - changed files: " @mods
prep: cp -R @mods ./target/
prep: cp -R @mods ./output/.target/
}

src/scss/**/*.scss {
prep: echo "SCSS - changed files: " @mods
prep: sass src/scss/Main.scss target/css/main.css
prep: sass src/scss/Main.scss ./output/.target/css/main.css
}

target/**/* {
# --address="127.0.0.1" # Address to listen on
# --all # Listen on all addresses
# --port=PORT # Port to listen on - if not specified, devd will auto-pick a sensible port

# --down=N # Throttle downstream from the client to N kilobytes per second
# --up=N # Throttle upstream from the client to N kilobytes per second
# --latency=N # Add N milliseconds of round-trip latency

# --crossdomain # Set the CORS header Access-Control-Allowed: *
# --logheaders # Log headers
# --logtime # Log timing
daemon: devd --color --livewatch --notimestamps ./target
daemon: parcel --out-dir ./output/.dist ./output/.target/index.html
}
@@ -16,19 +16,7 @@ import PRNG as PRNG

type State = Maybe Buffer
data Action = Regenerate
--data Query a = Regenerate a

-- Why are we using Aff rather than Effect?
-- ===========================================
-- For convenience –when it's time to run our UI– Halogen expects an Aff here.
-- It is possible to hoist a component and change the m type, but it's easier if we just use Aff in the first place.
-- Aff can do anything Effect can, so we're not losing out, just admitting more possibilities than we might need.

-- hoist => https://pursuit.purescript.org/packages/purescript-halogen/3.1.3/docs/Halogen.Component#v:hoist
-- Changes the component's m type. A use case for this would be to interpret some Free monad as Aff so the component can be used with runUI.

-- random :: Halogen.Component HTML.HTML Query Unit Void Aff
-- random = Halogen.component {
component :: forall q i o m. MonadAff m => Halogen.Component HTML.HTML q i o m
component = Halogen.mkComponent {
initialState,
@@ -38,11 +26,9 @@ component = Halogen.mkComponent {

where

-- initialState :: State
initialState :: forall i. i -> State
initialState _ = Nothing

-- render :: State -> Halogen.ComponentHTML Query
render :: forall m. State -> Halogen.ComponentHTML Action () m
render state =
let
@@ -51,21 +37,11 @@ component = Halogen.mkComponent {
HTML.div [] [
HTML.h1 [] [HTML.text "Random number"],
HTML.p [] [HTML.text ("Current value: " <> value)],
HTML.button [ Events.onClick \_ -> Just Regenerate] [ HTML.text "Generate new number" ]
HTML.button [ Events.onClick \_ -> Just Regenerate] [ HTML.text "Generate new random value" ]
]

-- eval :: Query ~> Halogen.ComponentHTML Action Unit m
-- eval = case _ of
-- Regenerate next -> do
-- -- liftEffect => https://pursuit.purescript.org/packages/purescript-effect/2.0.0/docs/Effect.Class#v:liftEffect
-- -- `liftEffect` can be used in any appropriate monad transformer stack to lift an action of type `Effect a` into the monad.
-- newNumber <- Halogen.liftEffect (Random.randomInt 0 255)
-- Halogen.put (Just newNumber)
-- pure next

handleAction forall o m. MonadAff m => Action Halogen.HalogenM State Action () o m Unit
handleAction = case _ of
Regenerate -> do
-- newNumber <- Halogen.liftEffect (Random.randomInt 0 255)
newNumber <- Halogen.liftEffect (PRNG.randomBytes 8)
Halogen.modify_ \st -> (Just newNumber)

0 comments on commit 7c4ce7b

Please sign in to comment.
You can’t perform that action at this time.