Giter VIP home page Giter VIP logo

cask-web's Introduction

Overview

Install

You need to explicitly install the following software:

Other software will be downloaded automatically by the commands below.

Prepare

$ npm install

Development

frontend

  • 1st terminal (scala -> javascript)

    $ sbt ~fastLinkJS
  • 2nd terminal (vite dev server)

    $ npm run dev

아래 주소로 frontend 확인 가능함 http://localhost:5173

backend

  • 3rd terminal (backend api server)
    $ sbt ~backend/reStart

아래 주소로 Backend API 를 직접 확인 가능함 http://localhost:8080/hello

Production (Basic)

frontend

# $npm ci
$ npm run build

You can then find the built files in the dist/ directory. You will need an HTTP server, such as python3 -m http.server, to open the files, as Vite rewrites <script> tags to prevent cross-origin requests.

frontend 와 backend 를 각각 분리해 배포

Production (Simple)

One Jar 로 만들어 backend server 에서 html, js 서빙하기

Dockerfile 의 ENTRYPOINT 확인

"caskweb.Main"

frontend 를 포함해 one-jar (app.jar) 로 만들기

npm run build

rsync -av --delete dist backend/src/main/resources/dist
# rm -rf backend/src/main/resources/dist 
# mv dist backend/src/main/resources/dist 

sbt backend/assembly  # backend/target/scala-2.13/app.jar

# java -cp app.jar caskweb.Main
# http://localhost:8080 로 확인

Dockerfile 을 이용해 docker image 생성

docker build --tag demoscalaflyio .
docker run --rm -p 9000:8080 demoscalaflyio

개발 가이드

  • main.js 에 의존성 있는(최종 index.html 에서 link(css) 혹은 script(js) 등으로 참조되어야 할) resource (js, css) 를 import 하면 npm run builddist/assets 디렉토리에 모이게 된다. (js 파일은 bundling 됨)
  • main.js 에서 import 하지 않지만 필요한 리소스(이미지 파일 등) 은 frontend/public 디렉토리에 넣는다.(vite.config.js 파일에서 publicDir 을 frontend/public 으로 설정했음) npm run builddist/ 디렉토리에 모이게 된다. vite-public-directory
    • You should always reference public assets using root absolute path - for example, public/icon.png should be referenced in source code as /icon.png
    • Assets in public cannot be imported from JavaScript.
  • main.js 에서 사용하는 @public 의 위치는 frontend\target\scala-2.13\frontend-opt 혹은 frontend\target\scala-2.13\frontend-fastopt 가 될 수 있다.

cask-web's People

Contributors

windbird123 avatar

Watchers

 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.