mirror of
https://github.com/zhigang1992/styled-components.git
synced 2026-04-29 01:35:53 +08:00
fix: use webpack .hooks API instead of deprecated Tapable.plugin
This commit is contained in:
@@ -19,15 +19,20 @@ const waitUntilValid = new Promise(next => devMiddleware.waitUntilValid(next));
|
||||
const waitMiddleware = (req, res, next) => waitUntilValid.then(next);
|
||||
|
||||
multiCompiler.compilers.forEach(compiler => {
|
||||
compiler.plugin('after-emit', (compilation, callback) => {
|
||||
Object.keys(require.cache).forEach(cachedFile => {
|
||||
if (cachedFile.startsWith(path.resolve(SANDBOX_PATHS.outputPath))) {
|
||||
delete require.cache[cachedFile];
|
||||
}
|
||||
});
|
||||
compiler.hooks.afterEmit.tapAsync(
|
||||
{
|
||||
name: 'ClearSandboxCache',
|
||||
},
|
||||
(compilation, callback) => {
|
||||
Object.keys(require.cache).forEach(cachedFile => {
|
||||
if (cachedFile.startsWith(path.resolve(SANDBOX_PATHS.outputPath))) {
|
||||
delete require.cache[cachedFile];
|
||||
}
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
callback();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
module.exports = next => composeMiddleware(waitMiddleware, devMiddleware, hotMiddleware)(next);
|
||||
|
||||
Reference in New Issue
Block a user