我使用TypeScript生成webpack配置。
根据vue-loader documentation,我安装了vue-loader
和vue-template-compiler
。
我确保vue-loader
有类型定义文件:
但是,我的TypeScript项目没有看到plugin.js文件。
TS2307: Cannot find module 'vue-loader/lib/plugin'.
我试过"allowJs": true
:没有效果。
另外,如果要通过@ts-ignore
来抑制错误消息,我的应用程序将由webpack成功构建。所以问题有些遗漏了声明。哪个是?
我的tsconfig.json
设置是:
{
"compilerOptions": {
"target": "es6",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"lib": [
"es2018"
],
"baseUrl": "./",
"noUnusedLocals": false,
"noUnusedParameters": false
}
}
TS7016: Could not find a declaration file for module 'vue-loader/lib/plugin'
node_modules/vue-loader/lib/index.d.ts
的内容是:
import { Plugin } from 'webpack'
declare namespace VueLoader {
class VueLoaderPlugin extends Plugin {}
}
export = VueLoader
你是这样尝试的:import { VueLoaderPlugin } from "vue-loader";
这对我有用。
您可以将插件导入到typescript中,如下所示:
import * as VueLoaderPlugin from 'vue-loader/lib/plugin';
之后你应该得到一大堆与consolidate相关的错误,Consolidate - Webpack build fails #295是node.js的模板引擎整合库。
我尝试使用类似于qazxswpoi的方法修复这些错误,但无法获得有效的webpack配置。