Help us understand the problem. What is going on with this article?

Nuxt.js を IntelliJ から利用した際に、 `@` や `~` alias を解決してくれない対処

More than 1 year has passed since last update.

Nuxt.js を公式サイト通りにセットアップ後にIntelliJで起動した場合、 以下のようなComponentなどで利用する ~@Cmd+Click で直接飛ぶことが出来なくて不便だった。

import HelloWorld from '~/components/HelloWorld.vue'

環境

"nuxt": "^2.0.0",

対処方法

nuxt.config.js へ以下を書き足し、 IntelliJ側の Webpack configuration を変更することで解決した。

nuxt.config.js
// 追加
const path = require('path');

module.exports = {
  ...
  // 追加
  resolve: {
    extensions: ['.js', '.json', '.vue', '.ts'],
    root: path.resolve(__dirname),
    alias: {
      '@': path.resolve(__dirname),
      '~': path.resolve(__dirname),
    },
  },
}

Preference -> Languages & Frameworks -> webpack -> webpack configuration file

/Users/xxxx/project/webpack.config.js

/Users/xxxx/project/nuxt.config.js

Nuxtjs♡IntelliJ

sutoh
Like: PG/Ruby/Rails/Mac/GitHub/VB/JS/iOS/vim/Linux/AWS/PHP/Analytics/BigQuery/ Web♡Ruby
http://aquari.hatenablog.jp/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした