我想用:
require.context('../images/', true, /\.(png|ico|svg|jpg|gif)$/)
但是我收到以下错误:
NodeRequire类型
上不存在属性上下文
答案 0 :(得分:9)
只需安装ValueTask
webpack-env
答案 1 :(得分:2)
并在 tsconfig.json 中将其添加到 types 属性中 例子:
{
"compilerOptions": {
"outDir": "./dist/",
"declaration": true,
"declarationDir": "./dist/",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6",
"allowJs": false,
"types": [
"node",
"webpack-env"
]
},
"files": [
"src/index.ts"
],
"compileOnSave": false
}