N
N
neonme2021-11-14 20:28:23
Vue.js
neonme, 2021-11-14 20:28:23

How to configure vue.config.js with typescript?

Hello, this is my first time working with typescript and when trying to set up 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 get EsLint 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");
    |                 ^

What have I done wrong...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neonme, 2021-11-14
@neonme

Thanks Aetae ,
Since it's a js file use import webpack = require("webpack"); I can't - just const webpack = require("webpack");
The problem really only with EsLint was
solved by adding to the beginning

/* eslint @typescript-eslint/no-var-requires: "off" */

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question