7
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 5 years have passed since last update.

ElectronアプリもTypeScriptで書きたい

Last updated at Posted at 2018-06-20

webpackでビルドしてから実行でもいいですが、そのまま起動できるとうれしいと思いませんか?ぼくは思いました。

やりかた

  1. npm i ts-node
  2. TypeScriptで適当にコードを書く
  3. 適当なところにindex.jsを作る

以下のような感じで、tsのエントリポイントをロードする

index.js
require("ts-node").register();
require("./src/main"); // src/main/index.ts がエントリポイントとする

あとは、

$ electron .

すればアプリが起動します。
以上です。よろしくおねがいいたします。

ちゅうい

おそらくですが、アプリの起動時にts-nodeによるトランスパイルを行っているので、動作は遅くなると思います。
実際にバイナリとして出力するときは、きちんとjsとして出力してあげたほうがいいんじゃないかなと思います。

7
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
7
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?