nuxt / typescript

TypeScript Support for Nuxt 2

Home Page:https://typescript.nuxtjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom tsconfig.json does not work with ForkTsCheckerWebpackPlugin

rkgrep opened this issue · comments

Describe the bug
Providing custom tsconfig.json file in configFile parameter for loaders does affect configuration of ForkTsCheckerWebpackPlugin
Path to file is hardcoded on this line

To Reproduce

  1. Rename tsconfig.json to tsconfig.nuxt.json
  2. Add configFile parameter to loader configuration (see additional context for example)
  3. Run nuxt build

Expected behavior
Everything should work fine.

Additional context
Sample config:

loaders: {
    ts: {
      configFile: 'tsconfig.nuxt.json',
    },
    tsx: {
      configFile: 'tsconfig.nuxt.json',
    },
  },

Console log:

 FATAL  Cannot find the "/home/rkgrep/Code/nuxt-project/tsconfig.json" file.                               10:45:53
Please check webpack and ForkTsCheckerWebpackPlugin configuration.
Possible errors:
  - wrong `context` directory in webpack configuration (if `configFile` is not set or is a relative path in the fork plugin configuration)
  - wrong `typescript.configFile` path in the plugin configuration (should be a relative or absolute path)

  Please check webpack and ForkTsCheckerWebpackPlugin configuration.

You'd also need to override typeCheck option. Something like:

typescript: {
  loaders: {
    ts: {
      configFile: 'tsconfig.nuxt.json',
    },
    tsx: {
      configFile: 'tsconfig.nuxt.json',
    },
  },
  typeCheck: {
    typescript: {
      configFile: 'tsconfig.nuxt.json'
    }
  }
}

But note that you might have to resolve and provide full path to the file.