2017-01-30 5 views
1

webpackを使用してjsファイルを保存時にバンドルしたいとします。Visual Studioのキーバインドでnpmコマンドを実行します。コード

これはウェブパックウォッチを使用して最も効果的です。しかし何でも...

私のグーグル・グーグルの結果は以下の通りですが、私はある時点で誰かに役立つことを願っています。

+0

だ入力を続行+スペース: http://stackoverflow.com/questions/29996145/visual-studio-code-compile-on-save –

+0

私はwebpackがファイルを見ていると思っています。簡単にセットアップできます。 –

答えて

1

NSCを使用して、VSC ...またはtypescriptのコンパイルのような任意のnpmコマンドで保存時にwebpackバンドルを実行します。

プロジェクトに.vscode/tasks.jsonを追加します。

{ 
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format 
    "command": "npm", 
    "isShellCommand": true, 
    "showOutput": "never", 
    "suppressTaskName": true, 
    "tasks": [ 
     { 
      "taskName": "bundle", 
      "args": ["run", "bundle"], 
      "isBuildCommand": true, 
      "showOutput": "never" 
     } 
    ] 
} 

編集keybindings.json(ファイル]> [設定]> [キーボードショートカット)。

// Place your key bindings in this file to overwrite the defaults 
[ 
    { 
     "key" : "ctrl+s", 
     "command" : "workbench.action.tasks.build" 
    } 
] 

workbench.action.tasks.buildは、ビルトインのvscフックです。ここを参照してください:https://code.visualstudio.com/docs/customization/keybindings#_tasks

タスクも経由VSCにアクセスすることができ

  1. Ctrl+P
  2. タイプtask
  3. は、あなたのタスクが提案参照するか、それが関連する名前
関連する問題