mirror of
https://github.com/zhigang1992/create-react-app.git
synced 2026-01-12 22:46:30 +08:00
- [x] Utilize webpack 4 development and production modes - [x] Upgrade webpack dev server - [x] Webpack 4 compatible release of thread-loader - [x] Webpack 4 compatible release of HtmlWebpackPlugin - [x] Webpack 4 compatible release of SwPrecacheWebpackPlugin - [x] Webpack 4 compatible release of WebpackManifestPlugin - [x] Update README - [x] Update WebpackDevServerUtils - [x] Update InterpolateHtmlPlugin - [x] Update ModuleScopePlugin - [x] Update WatchMissingNodeModulesPlugin - [x] Move UglifyJS options to webpack 4 optimize - [x] Move InterpolateHtmlPlugin to make it tapable on HtmlWebpackPlugin - [x] vendor splitting via splitChunks.splitChunks (https://twitter.com/wSokra/status/969633336732905474) - [x] long term caching via splitChunks.runtimeChunk (https://twitter.com/wSokra/status/969679223278505985) - [x] Make sure process.env.NODE_ENV is proxied correctly to `react-error-overlay` - [x] Implicit webpack.NamedModulesPlugin in dev config as its default in webpack 4 - [x] Disable webpack performance hints as we have our own filesize reporter - [x] Replace ExtractTextPlugin with MiniCssExtractPlugin - [x] Switch to css whole file minification via OptimizeCSSAssetsPlugin rather than per module css minification to gain performance
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
/**
|
||
* Copyright (c) 2015-present, Facebook, Inc.
|
||
*
|
||
* This source code is licensed under the MIT license found in the
|
||
* LICENSE file in the root directory of this source tree.
|
||
*/
|
||
|
||
// This Webpack plugin ensures `npm install <library>` forces a project rebuild.
|
||
// We’re not sure why this isn't Webpack's default behavior.
|
||
// See https://github.com/facebook/create-react-app/issues/186.
|
||
|
||
'use strict';
|
||
|
||
class WatchMissingNodeModulesPlugin {
|
||
constructor(nodeModulesPath) {
|
||
this.nodeModulesPath = nodeModulesPath;
|
||
}
|
||
|
||
apply(compiler) {
|
||
compiler.hooks.emit.tap('WatchMissingNodeModulesPlugin', compilation => {
|
||
var missingDeps = Array.from(compilation.missingDependencies);
|
||
var nodeModulesPath = this.nodeModulesPath;
|
||
|
||
// If any missing files are expected to appear in node_modules...
|
||
if (missingDeps.some(file => file.includes(nodeModulesPath))) {
|
||
// ...tell webpack to watch node_modules recursively until they appear.
|
||
compilation.contextDependencies.add(nodeModulesPath);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
module.exports = WatchMissingNodeModulesPlugin;
|