Giter Site home page Giter Site logo

duct-figwheel-component's Introduction

Duct-Figwheel-Component

A component for the Figwheel development tool, designed to be used in the Duct framework (but can be used in any component-based system).

Installation

Add the following dependency to your project.clj:

[duct/figwheel-component "0.3.3"]

Usage

Require the library and the Component library:

(require '[duct.component.figwheel :as figwheel]
         '[com.stuartsierra.component :as component])

Setup the component with a Figwheel-compatible configuration:

(def figwheel
  (figwheel/server
   {:css-dirs ["resources/public/css"]
    :builds
    [{:source-paths ["src/cljs"]
      :build-options
      {:output-to "target/figwheel/public/main.js"
       :output-dir "target/figwheel/public"
       :optimizations :none}}]}))

Start the server:

(alter-var-root #'figwheel component/start)

Ensure that the client ClojureScript starts Figwheel as well:

(figwheel.client/start {:websocket-url "ws://localhost:3449/figwheel-ws"})

Unlike the Leiningen plugin of Figwheel, this component does not trigger builds automatically. Instead, you have the following functions at the REPL:

(figwheel/build-cljs figwheel)    ;; build modified cljs files
(figwheel/rebuild-cljs figwheel)  ;; build all cljs files
(figwheel/refresh-css figwheel)   ;; refresh CSS files

Running any of those functions will cause the updated code to be pushed over websocket to any open clients.

You can also start a Piggieback REPL over the Figwheel connection:

(figwheel/cljs-repl figwheel)           ;; uses first build
(figwheel/cljs-repl figwheel build-id)  ;; uses specific build-id

This REPL will allow you to evaluate ClojureScript on the browser.

To stop the server:

(alter-var-root #'figwheel component/stop)

License

Copyright © 2016 James Reeves

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

duct-figwheel-component's People

Contributors

weavejester avatar ggiraldez avatar

Watchers

James Cloos avatar

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.