LoginSignup
1
1

More than 1 year has passed since last update.

VSCode: Live Serverで文字コードがUTF-8以外の場合

Last updated at Posted at 2022-01-21

訳合って、文字コードをEUC-JPでコーディングを行う必要があったのですが、いつもどおりVS CodeのLive Serverを利用したところ見事に文字化けてしまいました。

時間をかけて調べてみましたがLive Severのままでは解決できそうにありませんでした。
issueもいくつかあがっているようです。

また、こちらのissueを参考にlive-reloadのindex.jsを直接いじるということも試してみたのですが、設定方法が悪かったのか動作しませんでした。

そこで、node-staticを利用することにしました。(今回はグローバルインストールで進めます。)

インストール、 実行方法

npm install node-static -g

あとは、対象のディレクトリで実行するだけです。

cd [target_dir]
static

ただこれだけだと、ブラウザがキャッシュを持ってしまい開発に不向きなので、
キャッシュを持たせないようno-cacheを設定できます。

static -H '{"Cache-Control": "no-cache"}'

参考記事

VSCode の Live Server で文字コード Shift_JIS が文字化けしてしまう

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