mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
* feat(webpack-dev-middleware): update to v3.7 - v2 created - update configuration options to v3.7 https://github.com/webpack/webpack-dev-middleware/tree/v3.7.2#options Thanks! * fix(webpack-serve): fix v1 tests errors - `The types of 'dev.logLevel' are incompatible between these types` - `Types of property 'dev' are incompatible` Required to pass test for `webpack-dev-middleware` changes
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
import express = require('express');
|
|
import webpack = require('webpack');
|
|
import webpackDevMiddleware = require('webpack-dev-middleware');
|
|
|
|
const compiler = webpack({});
|
|
|
|
let webpackDevMiddlewareInstance = webpackDevMiddleware(compiler);
|
|
|
|
webpackDevMiddlewareInstance = webpackDevMiddleware(compiler, {
|
|
logLevel: 'silent',
|
|
logTime: true,
|
|
lazy: true,
|
|
methods: ['GET', 'POST'],
|
|
mimeTypes: {
|
|
typeMap: { 'text/html': ['phtml'] },
|
|
force: true,
|
|
},
|
|
watchOptions: {
|
|
aggregateTimeout: 300,
|
|
poll: true,
|
|
},
|
|
publicPath: '/assets/',
|
|
index: 'index.html',
|
|
headers: {
|
|
'X-Custom-Header': 'yes',
|
|
},
|
|
stats: {
|
|
colors: true,
|
|
},
|
|
reporter: null,
|
|
serverSideRender: false,
|
|
writeToDisk: false,
|
|
});
|
|
|
|
const app = express();
|
|
app.use([webpackDevMiddlewareInstance]);
|
|
|
|
webpackDevMiddlewareInstance.close(() => {
|
|
console.log('closed');
|
|
});
|
|
|
|
webpackDevMiddlewareInstance.invalidate(stats => {
|
|
if (stats) {
|
|
console.log(stats.toJson());
|
|
}
|
|
});
|
|
|
|
webpackDevMiddlewareInstance.waitUntilValid(stats => {
|
|
if (stats) {
|
|
console.log('Package is in a valid state:' + stats.toJson());
|
|
}
|
|
});
|
|
|
|
const fs = webpackDevMiddlewareInstance.fileSystem;
|
|
fs.mkdirpSync('foo');
|
|
|
|
let filename = webpackDevMiddlewareInstance.getFilenameFromUrl('url');
|
|
if (filename !== false) {
|
|
filename = filename.substr(0);
|
|
}
|