最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use Webpacks 'require' and 'require.ensure' in TypesScript - Stack Overflow

programmeradmin0浏览0评论

I am trying to integrate TypeScript into Webpack and am looking for some @types that will help with all the Webpack specific stuff.

I was using declare function require(string): any; to use fe.: require('some.scss') but quickly got annoyed with adding it directly or over the /// <reference path="... syntax and was hoping that there is a better way to do this.

The ideal thing would be just npm i @types/webpack but that package only seems to be for the Webpack config file which I think is totally useless...

to be more specific, I am trying to get this code to work in TypeScript:

require.ensure([
    require('./first')
], function(require) {
    require('./second')
}, 'second');

I am trying to integrate TypeScript into Webpack and am looking for some @types that will help with all the Webpack specific stuff.

I was using declare function require(string): any; to use fe.: require('some.scss') but quickly got annoyed with adding it directly or over the /// <reference path="... syntax and was hoping that there is a better way to do this.

The ideal thing would be just npm i @types/webpack but that package only seems to be for the Webpack config file which I think is totally useless...

to be more specific, I am trying to get this code to work in TypeScript:

require.ensure([
    require('./first')
], function(require) {
    require('./second')
}, 'second');
Share Improve this question edited Jan 12, 2017 at 13:56 Liam 29.8k28 gold badges138 silver badges202 bronze badges asked Jan 12, 2017 at 13:50 BrendanMullinsBrendanMullins 5873 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

These are available in @types/webpack-env

npm install --save-dev @types/webpack-env
发布评论

评论列表(0)

  1. 暂无评论