Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RubyMineでwebpackのモジュールパスを解決する #814

Open
tomoyukikashiro opened this issue Aug 1, 2022 · 0 comments
Open

RubyMineでwebpackのモジュールパスを解決する #814

tomoyukikashiro opened this issue Aug 1, 2022 · 0 comments

Comments

@tomoyukikashiro
Copy link
Owner


date: 2019-02-18
title: RubyMineでwebpackのモジュールパスを解決する
summary: ~や@から指定するモジュールのパスをRubyMineで解決する方法を説明します。
slug: resolve-webpack-module-path-for-rubymine
lang: ja-JP

ユースケース

components
├── shared
│   ├── ErrorMessage.vue
│   ├── Loading.vue
│   ├── Pagination.vue

こんなコンポーネント郡があり、components/shared/Loading.vuecomponents/shared/ErrorMessage.vue を読み込む場合に、@~を使って絶対パス風に書くことがあります。

import ErrorMessage from '@/components/shared/ErrorMessage.vue'

この場合に、webpackのモジュールパスの設定をRubyMineにも設定しておくと、Go to DeclarationGo to Implementation でコンポーネント間の移動がしやすくなり、、Auto Completesでコード補完も効くようになります。

ダミーのwebpack.jsを作成する

プロジェクトにwebpackの設定ファイルがあればそれを流用できるのですが、 nextjsNuxt.jsGatsbyJS はフレームワーク内部にwebpackの設定ファイルが隠蔽されてしまっているので、パス解決用にダミーのファイルを作成します。

$ vi .idea/webpack.js

下記設定をコピー。(sourcePathは適宜変更してください。)

const path = require('path');
const sourcePath = path.resolve(path.join(__dirname, '..'))

module.exports = {
  resolve: {
    extensions: ['.js', '.json', '.vue', '.ts'],
    root: sourcePath,
    alias: {
      '@': sourcePath,
      '~': sourcePath
    }
  }
}

RubyMineの設定に該当ファイルを設定する

Languages & Frameworks > Javascript > Webpackにファイルのパスを入れる。
img

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant