User Tools

Site Tools


lecture:clojurescript:clojurescript_templates

clojurescript tempaltes

template이란?

가장 간단한 template

cljs-kickoff

cljs-template

project.cljs

(defproject test-cljs-template "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://exampl.com/FIXME"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [noir-cljs "0.3.7"]
                 [jayq "1.0.0"]
                 [fetch "0.1.0-alpha2" :exclusions [org.clojure/clojure]]
                 [crate "0.2.3"]
                 [noir "1.3.0"]]
  :cljsbuild {:builds [{}]}
  :main ^{:skip-aot true} test-cljs-template.server)

folders

.
├── README.md
├── externs
│   └── jquery.js
├── project.clj
├── resources
│   └── public
│       └── css
│           ├── default.css
│           └── reset.css
└── src
    └── test_cljs_template
        ├── client
        │   └── main.cljs
        ├── models
        │   └── user.clj
        ├── server.clj
        └── views
            ├── common.clj
            └── main.clj

mies

project.clj

(defproject test-mies "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2371"]]

  :plugins [[lein-cljsbuild "1.0.4-SNAPSHOT"]]

  :source-paths ["src"]

  :cljsbuild {
    :builds [{:id "test-mies"
              :source-paths ["src"]
              :compiler {
                :output-to "test_mies.js"
                :output-dir "out"
                :optimizations :none
                :source-map true}}]})

folders

.
├── index.html
├── project.clj
└── src
    └── test_mies
        └── core.cljs

chectnut

  • clojure/clojurescript/css project 구성 : Om + Ring, Figwheel, weasel
  • 간단하게 jetty 대신 http-kit을 바꿀 수 있다.
  • test로 specljs 사용.

project.clj

(defproject test-chestnut "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}

  :source-paths ["src/clj" "src/cljs"]

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2371" :scope "provided"]
                 [ring "1.3.1"]
                 [compojure "1.2.0"]
                 [enlive "1.1.5"]
                 [om "0.7.3"]
                 [figwheel "0.1.4-SNAPSHOT"]
                 [environ "1.0.0"]
                 [com.cemerick/piggieback "0.1.3"]
                 [weasel "0.4.0-SNAPSHOT"]
                 [leiningen "2.5.0"]]

  :plugins [[lein-cljsbuild "1.0.3"]
            [lein-environ "1.0.0"]]

  :min-lein-version "2.5.0"

  :uberjar-name "test-chestnut.jar"

  :cljsbuild {:builds {:app {:source-paths ["src/cljs"]
                             :compiler {:output-to     "resources/public/js/app.js"
                                        :output-dir    "resources/public/js/out"
                                        :source-map    "resources/public/js/out.js.map"
                                        :preamble      ["react/react.min.js"]
                                        :externs       ["react/externs/react.js"]
                                        :optimizations :none
                                        :pretty-print  true}}}}

  :profiles {:dev {:repl-options {:init-ns test-chestnut.server
                                  :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}

                   :plugins [[lein-figwheel "0.1.4-SNAPSHOT"]]

                   :figwheel {:http-server-root "public"
                              :port 3449
                              :css-dirs ["resources/public/css"]}

                   :env {:is-dev true}

                   :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"]}}}}

             :uberjar {:hooks [leiningen.cljsbuild]
                       :env {:production true}
                       :omit-source true
                       :aot :all
                       :cljsbuild {:builds {:app
                                            {:source-paths ["env/prod/cljs"]
                                             :compiler
                                             {:optimizations :advanced
                                              :pretty-print false}}}}}})

folders

.
├── LICENSE
├── Procfile
├── README.md
├── env
│   ├── dev
│   │   └── cljs
│   │       └── test_chestnut
│   │           └── dev.cljs
│   └── prod
│       └── cljs
│           └── test_chestnut
│               └── prod.cljs
├── project.clj
├── resources
│   ├── index.html
│   └── public
│       └── css
│           └── style.css
├── src
│   ├── clj
│   │   └── test_chestnut
│   │       ├── dev.clj
│   │       └── server.clj
│   └── cljs
│       └── test_chestnut
│           └── core.cljs
└── system.properties

cljs-kickoff

project.clj

(defproject test-cljs-kickoff "0.1.0-SNAPSHOT"
  :description "FIXME: write this!"
  :url "http://example.com/FIXME"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [org.clojure/clojurescript "0.0-2156"]
                 [ring "1.2.1"]]
  :plugins [[lein-cljsbuild "1.0.2"]
            [lein-ring "0.8.10"]]
  :hooks [leiningen.cljsbuild]
  :source-paths ["src/clj"]
  :cljsbuild {
    :builds {
      :main {
        :source-paths ["src/cljs"]
        :compiler {:output-to "resources/public/js/cljs.js"
                   :optimizations :simple
                   :pretty-print true}
        :jar true}}}
  :main test-cljs-kickoff.server
  :ring {:handler test-cljs-kickoff.server/app})

folders

.
├── project.clj
├── resources
│   └── public
│       ├── css
│       │   └── page.css
│       └── help.html
└── src
    ├── clj
    │   └── test_cljs_kickoff
    │       └── server.clj
    └── cljs
        └── test_cljs_kickoff
            └── client.cljs

주의점 자동생성되는 page.css의 스타일이 프로젝트에서 사용하기 위해 추가한 자바스크립트 라이브러리의 css와 충돌할 수 있다. 그런 경우 page.css를 제거해 주면된다.

cljs-start

project.clj

(defproject test-cljs-start "0.0.1-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License - v 1.0"
            :url "http://www.eclipse.org/legal/epl-v10.html"
            :distribution :repo}

  :min-lein-version "2.3.4"

  ;; We need to add src/cljs too, because cljsbuild does not add its
  ;; source-paths to the project source-paths
  :source-paths ["src/clj" "src/cljs"]

  :dependencies [[org.clojure/clojure "1.6.0"]
                 [org.clojure/clojurescript "0.0-2371"]]

  :plugins [[lein-cljsbuild "1.0.3"]]

  :hooks [leiningen.cljsbuild]

  :cljsbuild
  {:builds {;; This build is only used for including any cljs source
            ;; in the packaged jar when you issue lein jar command and
            ;; any other command that depends on it
            :test-cljs-start
            {:source-paths ["src/cljs"]
             ;; The :jar true option is not needed to include the CLJS
             ;; sources in the packaged jar. This is because we added
             ;; the CLJS source codebase to the Leiningen
             ;; :source-paths
             ;:jar true
             ;; Compilation Options
             :compiler
             {:output-to "dev-resources/public/js/test_cljs_start.js"
              :optimizations :advanced
              :pretty-print false}}}})

folders

.
├── LICENSE
├── README.md
├── dev-resources
│   ├── public
│   │   └── index.html
│   └── tools
│       ├── http
│       │   └── ring
│       │       └── server.clj
│       └── repl
│           └── brepl
│               └── connect.cljs
├── doc
│   └── intro.md
├── profiles.clj
├── project.clj
├── src
│   └── cljs
│       └── test_cljs_start
│           └── core.cljs
└── test
    └── cljs
        └── test_cljs_start
            └── core_test.cljs

cljsbuild-template

project.clj

(defproject test-cljsbuild-template "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.clojure/clojurescript "0.0-1450"]]
  :source-paths ["src/cljs"]
  :plugins [[lein-cljsbuild "0.2.7"]]
  :hooks [leiningen.cljsbuild]
  :min-lein-version "2.0.0"
  :cljsbuild {:repl-listen-port     9000
              :repl-launch-commands {"phantom"       ["phantomjs"
                                                      "phantom/repl.js"
                                                      :stdout ".repl-phantom-out"
                                                      :stderr ".repl-phantom-err"]
                                     "phantom-naked" ["phantomjs"
                                                      "phantom/repl.js"
                                                      "resources/private/html/naked.html"
                                                      :stdout ".repl-phantom-naked-out"
                                                      :stderr ".repl-phantom-naked-err"]}
              :test-commands        {"unit" ["phantomjs"
                                             "phantom/unit-test.js"
                                             "resources/private/html/unit-test.html"]}
              :builds               {:dev  {:source-path "src/cljs"
                                            :compiler    {:output-to     "resources/public/js/main-debug.js"
                                                          :optimizations :simple
                                                          :pretty-print  true}}
                                     :prod {:source-path "src/cljs"
                                            :compiler    {:output-to     "resources/public/js/main.js"
                                                          :optimizations :advanced
                                                          :pretty-print  false}}
                                     :test {:source-path "test/cljs"
                                            :compiler    {:output-to     "resources/private/js/unit-test.js"
                                                          :optimizations :whitespace
                                                          :pretty-print  true}}}})

folders

.
├── README.md
├── phantom
│   ├── repl.js
│   └── unit-test.js
├── project.clj
├── resources
│   └── private
│       └── html
│           ├── naked.html
│           └── unit-test.html
├── src
│   └── cljs
│       └── repl.cljs
└── test
    └── cljs
        └── test_cljsbuild_template
            ├── test
            │   └── feature1.cljs
            └── test.cljs
lecture/clojurescript/clojurescript_templates.txt · Last modified: 2019/02/04 14:26 (external edit)