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

Edit tsconfig.json file path #545

Closed
nbl7 opened this issue Mar 14, 2022 · 3 comments · Fixed by #594
Closed

Edit tsconfig.json file path #545

nbl7 opened this issue Mar 14, 2022 · 3 comments · Fixed by #594

Comments

@nbl7
Copy link

nbl7 commented Mar 14, 2022

It is not possible to edit the default tsconfig.json file path. The following will make it possible:

diff --git a/node_modules/@nuxt/typescript-build/dist/index.js b/node_modules/@nuxt/typescript-build/dist/index.js
index 2a18933..596f679 100644
--- a/node_modules/@nuxt/typescript-build/dist/index.js
+++ b/node_modules/@nuxt/typescript-build/dist/index.js
@@ -38,9 +38,11 @@ const tsModule = function (moduleOptions) {
         })));
         if (options.typeCheck && isClient && !isModern) {
             const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
+            const configFile = (this.options?.typescript?.configFile !== undefined) ? this.options.typescript.configFile : path_1.default.resolve(this.options.rootDir, 'tsconfig.json');
             config.plugins.push(new ForkTsCheckerWebpackPlugin(Object.assign({
                 typescript: {
-                    configFile: path_1.default.resolve(this.options.rootDir, 'tsconfig.json'),
+                    // configFile: path_1.default.resolve(this.options.rootDir, 'tsconfig.json'),
+                    configFile: configFile,
                     extensions: {
                         vue: true
                     }

This issue body was partially generated by patch-package.

@Kapcash
Copy link

Kapcash commented Feb 15, 2023

I also need this so I can specify a production only tsconfig.json file (like tsconfig.production.json) and disable its sourcemaps.

@kevinmarrec would it be possible to create a new release if we create a PR with this change?

@rchl
Copy link
Collaborator

rchl commented Mar 25, 2023

Why were you saying that it was not possible? This code was merging module's typeCheck object with those default options so it was possible to override them. The only catch was that you had to duplicate all default options (so also the extensions object) since merge wasn't deep but that's fixed now also.

@rchl rchl closed this as completed Mar 25, 2023
@Kapcash
Copy link

Kapcash commented Apr 5, 2023

Thanks @rchl for pointing out the module is actually merging the module options to the webpack plugin configuration.
So we can already override the tsconfig path like this in module options (nuxt.config.js):

['@nuxt/typescript-build', {
   typeCheck: {
      typescript: {
         configFile: path.resolve('.', 'tsconfig.prod.json'),
      },
   },
}],

This behaviour is not documented though.

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

Successfully merging a pull request may close this issue.

3 participants