mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-04 19:42:46 +08:00
Added types for koa-webpack
This commit is contained in:
33
types/koa-webpack/index.d.ts
vendored
Normal file
33
types/koa-webpack/index.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Type definitions for koa-webpack 1.0
|
||||
// Project: https://github.com/shellscape/koa-webpack#readme
|
||||
// Definitions by: Luka Maljic <https://github.com/malj>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import * as Koa from 'koa'
|
||||
import * as webpack from 'webpack'
|
||||
import * as webpackDevMiddleware from 'webpack-dev-middleware'
|
||||
import * as webpackHotMiddleware from 'webpack-hot-middleware'
|
||||
import { NextHandleFunction } from 'connect'
|
||||
|
||||
declare function koaWebpack(
|
||||
options?: koaWebpack.Options
|
||||
): Koa.Middleware & koaWebpack.CombinedWebpackMiddleware
|
||||
|
||||
declare namespace koaWebpack
|
||||
{
|
||||
interface Options
|
||||
{
|
||||
compiler?: webpack.Compiler
|
||||
config?: webpack.Configuration
|
||||
dev?: webpackDevMiddleware.Options
|
||||
hot?: webpackHotMiddleware.Options
|
||||
}
|
||||
|
||||
interface CombinedWebpackMiddleware
|
||||
{
|
||||
dev: NextHandleFunction & webpackDevMiddleware.WebpackDevMiddleware
|
||||
hot: NextHandleFunction & webpackHotMiddleware.EventStream
|
||||
}
|
||||
}
|
||||
|
||||
export = koaWebpack
|
||||
50
types/koa-webpack/koa-webpack-tests.ts
Normal file
50
types/koa-webpack/koa-webpack-tests.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import * as Koa from 'koa'
|
||||
import * as webpack from 'webpack'
|
||||
import * as koaWebpack from 'koa-webpack'
|
||||
|
||||
const app = new Koa()
|
||||
const config: webpack.Configuration = {}
|
||||
const compiler = webpack(config)
|
||||
|
||||
|
||||
// Using the middleware
|
||||
|
||||
const middleware = koaWebpack({
|
||||
compiler,
|
||||
config,
|
||||
dev: {
|
||||
noInfo: false,
|
||||
quiet: false,
|
||||
lazy: true,
|
||||
watchOptions: {
|
||||
aggregateTimeout: 300,
|
||||
poll: true,
|
||||
},
|
||||
publicPath: '/assets/',
|
||||
index: 'index.html',
|
||||
headers: {
|
||||
'X-Custom-Header': 'yes'
|
||||
},
|
||||
stats: {
|
||||
colors: true,
|
||||
},
|
||||
reporter: null,
|
||||
serverSideRender: false
|
||||
},
|
||||
hot: {
|
||||
log: console.log.bind(console),
|
||||
path: '/__what',
|
||||
heartbeat: 2000
|
||||
}
|
||||
})
|
||||
|
||||
app.use(middleware)
|
||||
|
||||
|
||||
// Accessing the underlying middleware
|
||||
|
||||
middleware.dev.close()
|
||||
middleware.dev.invalidate()
|
||||
middleware.dev.waitUntilValid()
|
||||
middleware.hot.publish(null)
|
||||
|
||||
22
types/koa-webpack/tsconfig.json
Normal file
22
types/koa-webpack/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"koa-webpack-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/koa-webpack/tslint.json
Normal file
1
types/koa-webpack/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user