5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

svelteの開発環境の作り方

Last updated at Posted at 2020-07-24

(2021-06-09追記)
フロントエンド開発においては、無理にdockerを使う必要はありません。
理由は、dockerを使うことで開発PCの負荷が高くなり、ビルド時間などが延びてDXが悪化します。
nodeバージョンを揃えるにはvoltaなどのバージョン管理がオススメです。

開発環境

  • macOS Catalina
  • docker -v @19.03.8

開発環境の作り方

svelteプロジェクト作成

npx degit sveltejs/template svelte-spa
cd svelte-spa

Dockerからlocalhostにつなげるための設定

package.json
  "scripts": {
    "build": "rollup -c",
    "dev": "rollup -c -w",
-   "start": "sirv public"
+   "start": "sirv public build --host 0.0.0.0"
  },

Dockerfileを作成

touch Dockerfile
Dockerfile
FROM node:12-alpine
COPY package.json ./
RUN npm install
COPY . .
EXPOSE 5000
ENV HOST=0.0.0.0
CMD [ "npm", "start" ]

Docker起動を確認

docker build -t svelte/svelte-spa .
docker run -p 5000:5000 svelte/svelte-spa

http://0.0.0.0:5000/にアクセスしてsvelteのHelloWorldが開けることを確認

image.png

やった!

参考

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?