Nuxt.js: nuxt.config.ts

Created on 22 Feb 2018  路  3Comments  路  Source: nuxt/nuxt.js

Hello,
I'm a typescript user and I would like to know if it would be possible to write the config file in typescript as it is possible for gulp with the use of ts-node. What I have in mind is to be able to import ts files in config to use some code in generate/routes for instance.
Thank you.

This question is available on Nuxt.js community (#c2501)

Most helpful comment

  1. Install dependencies in the project
    cmd > yarn add ts-node typescript -D
  2. In the file package.json replace to this:
    json { ... "dev": "node -r ts-node/register node_modules/nuxt/bin/nuxt dev -c nuxt.config.ts", "build": "node -r ts-node/register node_modules/nuxt/bin/nuxt build -c nuxt.config.ts", "generate": "node -r ts-node/register node_modules/nuxt/bin/nuxt generate -c nuxt.config.ts", ... }
  3. Run
    cmd > yarn dev OR > yarn build OR > yarn generate

References:

All 3 comments

You can definitely do it in many different ways if you use nuxt programmatically, but you may also want to try typescript-require.
This will probably become a native feature at some point.

  1. Install dependencies in the project
    cmd > yarn add ts-node typescript -D
  2. In the file package.json replace to this:
    json { ... "dev": "node -r ts-node/register node_modules/nuxt/bin/nuxt dev -c nuxt.config.ts", "build": "node -r ts-node/register node_modules/nuxt/bin/nuxt build -c nuxt.config.ts", "generate": "node -r ts-node/register node_modules/nuxt/bin/nuxt generate -c nuxt.config.ts", ... }
  3. Run
    cmd > yarn dev OR > yarn build OR > yarn generate

References:

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gary149 picture gary149  路  3Comments

vadimsg picture vadimsg  路  3Comments

pehbehbeh picture pehbehbeh  路  3Comments

surmon-china picture surmon-china  路  3Comments

mikekidder picture mikekidder  路  3Comments