Serio
Serio

Reputation: 527

How do I setup vue.config.js with typescript?

Hello I am working with typescript for the first time and when trying to configure vue.config.js

const webpack = require("webpack");
module.exports = {
    plugins: [
      new webpack.DefinePlugin({
        __VUE_I18N_FULL_INSTALL__: true,
        __VUE_I18N_LEGACY_API__: false,
        __VUE_I18N_PROD_DEVTOOLS__: false,
        __INTLIFY_PROD_DEVTOOLS__: false,
      }),
    ],
  },
};

I am getting an error

$ vue-cli-service lint
error: Require statement not part of import statement (@typescript-eslint/no-var-requires) at vue.config.js:1:17:
> 1 | const webpack = require("webpack");
    |                 ^

When creating a js project, everything worked. How can I fix it in ts project

Upvotes: 0

Views: 2192

Answers (1)

Serio
Serio

Reputation: 527

Thanks Estus, it was an ESLint error, not sure why, but ESLint is throwing a typescript syntax error in the js file. The solution is

/* eslint @typescript-eslint/no-var-requires: "off" */
const webpack = require("webpack");

Upvotes: 1

Related Questions