mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-22 17:47:53 +00:00
Add webpack 4 support to aspnet-webpack
This commit is contained in:
committed by
Steve Sanderson
parent
c35a3a17c0
commit
823630c508
File diff suppressed because it is too large
Load Diff
@@ -21,18 +21,18 @@
|
|||||||
"es6-promise": "^3.1.2",
|
"es6-promise": "^3.1.2",
|
||||||
"memory-fs": "^0.3.0",
|
"memory-fs": "^0.3.0",
|
||||||
"require-from-string": "^1.1.0",
|
"require-from-string": "^1.1.0",
|
||||||
"webpack-dev-middleware": "^1.8.4",
|
|
||||||
"webpack-node-externals": "^1.4.3"
|
"webpack-node-externals": "^1.4.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/connect": "^3.4.30",
|
"@types/connect": "^3.4.30",
|
||||||
"@types/node": "^6.0.42",
|
"@types/node": "^6.0.42",
|
||||||
"@types/webpack": "^2.2.0",
|
"@types/webpack": "^4.1.3",
|
||||||
"rimraf": "^2.5.4",
|
"rimraf": "^2.5.4",
|
||||||
"typescript": "^2.0.0",
|
"typescript": "^2.0.0",
|
||||||
"webpack": "^1.13.2"
|
"webpack": "^4.5.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"webpack": "^1.13.2 || ^2.1.0-beta || ^3.0.0"
|
"webpack": "^1.13.2 || ^2.1.0-beta || ^3.0.0 || ^4.0.0",
|
||||||
|
"webpack-dev-middleware": "^1.8.4 || ^3.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,9 +90,12 @@ function loadViaWebpackNoCache<T>(webpackConfigPath: string, modulePath: string)
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
// The CommonsChunkPlugin is not compatible with a CommonJS environment like Node, nor is it needed in that case
|
// The CommonsChunkPlugin is not compatible with a CommonJS environment like Node, nor is it needed in that case
|
||||||
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
|
const ChunkPlugin = webpack.optimize['CommonsChunkPlugin'];
|
||||||
return !(plugin instanceof webpack.optimize.CommonsChunkPlugin);
|
if (ChunkPlugin !== undefined) {
|
||||||
});
|
webpackConfig.plugins = webpackConfig.plugins.filter(plugin => {
|
||||||
|
return !(plugin instanceof ChunkPlugin);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
|
// The typical use case for DllReferencePlugin is for referencing vendor modules. In a Node
|
||||||
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
|
// environment, it doesn't make sense to load them from a DLL bundle, nor would that even
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
|
|||||||
const compiler = webpack(webpackConfig);
|
const compiler = webpack(webpackConfig);
|
||||||
app.use(require('webpack-dev-middleware')(compiler, {
|
app.use(require('webpack-dev-middleware')(compiler, {
|
||||||
noInfo: true,
|
noInfo: true,
|
||||||
|
stats: webpackConfig.stats,
|
||||||
publicPath: ensureLeadingSlash(webpackConfig.output.publicPath),
|
publicPath: ensureLeadingSlash(webpackConfig.output.publicPath),
|
||||||
watchOptions: webpackConfig.watchOptions
|
watchOptions: webpackConfig.watchOptions
|
||||||
}));
|
}));
|
||||||
@@ -133,9 +134,12 @@ function attachWebpackDevMiddleware(app: any, webpackConfig: webpack.Configurati
|
|||||||
// middleware's in-memory filesystem only (and not on disk) would confuse the debugger, because the
|
// middleware's in-memory filesystem only (and not on disk) would confuse the debugger, because the
|
||||||
// file on disk wouldn't match the file served to the browser, and the source map line numbers wouldn't
|
// file on disk wouldn't match the file served to the browser, and the source map line numbers wouldn't
|
||||||
// match up. Breakpoints would either not be hit, or would hit the wrong lines.
|
// match up. Breakpoints would either not be hit, or would hit the wrong lines.
|
||||||
(compiler as any).plugin('done', stats => {
|
const copy = stats => copyRecursiveToRealFsSync(compiler.outputFileSystem, '/', [/\.hot-update\.(js|json|js\.map)$/]);
|
||||||
copyRecursiveToRealFsSync(compiler.outputFileSystem, '/', [/\.hot-update\.(js|json|js\.map)$/]);
|
if (compiler.hooks) {
|
||||||
});
|
compiler.hooks.done.tap('aspnet-webpack', copy);
|
||||||
|
} else {
|
||||||
|
compiler.plugin('done', copy);
|
||||||
|
}
|
||||||
|
|
||||||
if (enableHotModuleReplacement) {
|
if (enableHotModuleReplacement) {
|
||||||
let webpackHotMiddlewareModule;
|
let webpackHotMiddlewareModule;
|
||||||
|
|||||||
Reference in New Issue
Block a user