1. 安装 webpack@types/webpack
npm install webpack @types/webpack --save-dev
  1. 打开 VS Code,在项目根目录下创建一个新文件夹 .vscode,在其中创建一个名为 settings.json 的文件。

  2. settings.json 文件中添加以下内容:

{
  'editor.quickSuggestions': {
    'other': true,
    'comments': false,
    'strings': true
  },
  'typescript.autoImportSuggestions.enabled': true,
  'javascript.suggest.autoImports': true,
  'typescript.suggest.autoImports': true,
  'typescript.preferences.importModuleSpecifier': 'relative',
  'typescript.preferences.quoteStyle': 'single',
  'typescript.referencesCodeLens.enabled': true,
  'javascript.referencesCodeLens.enabled': true,
  'typescript.surveys.enabled': false,
  'javascript.surveys.enabled': false,
  'javascript.validate.enable': false,
  'typescript.validate.enable': false,
  'javascript.format.enable': false,
  'typescript.format.enable': false,
  'typescript.tsserver.log': 'verbose',
  'typescript.tsserver.experimental.enableWorkspaceSymlinkSupport': true,
  'typescript.enablePromptUseWorkspaceTsdk': true,
  'typescript.updateImportsOnFileMove.enabled': 'always',
  'typescript.referencesCodeLens.showOnAllFunctions': true,
  'typescript.referencesCodeLens.showOnAllDeclarations': true,
  'editor.snippetSuggestions': 'top',
  'typescript.suggest.paths': true,
  'javascript.suggest.paths': true,
}
  1. 在 VS Code 中打开一个 TypeScript 或 JavaScript 文件,输入 import webpack from 'webpack';,如果提示符号出现,就表示成功添加了 webpack 的代码提示。

注意: 如果没有成功添加提示,可以尝试重启 VS Code。

VS Code 中添加 Webpack 代码提示 - 快速配置指南

原文地址: https://www.cveoy.top/t/topic/neHm 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录