|
|
|
@ -10,6 +10,7 @@ const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeM
|
|
|
|
|
const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
|
|
|
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
|
|
|
|
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
|
|
|
|
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
|
|
|
|
|
const getClientEnvironment = require('./env');
|
|
|
|
|
const paths = require('./paths');
|
|
|
|
|
|
|
|
|
@ -268,6 +269,27 @@ module.exports = {
|
|
|
|
|
// You can remove this if you don't use Moment.js:
|
|
|
|
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
|
|
|
new MonacoWebpackPlugin(),
|
|
|
|
|
new HardSourceWebpackPlugin({
|
|
|
|
|
// cacheDirectory是在高速缓存写入。默认情况下,将缓存存储在node_modules下的目录中,因此如
|
|
|
|
|
// 果清除了node_modules,则缓存也是如此
|
|
|
|
|
cacheDirectory: 'node_modules/.cache/hard-source/[confighash]',
|
|
|
|
|
// Either an absolute path or relative to webpack's options.context.
|
|
|
|
|
// Sets webpack's recordsPath if not already set.
|
|
|
|
|
recordsPath: 'node_modules/.cache/hard-source/[confighash]/records.json',
|
|
|
|
|
// configHash在启动webpack实例时转换webpack配置,并用于cacheDirectory为不同的webpack配
|
|
|
|
|
// 置构建不同的缓存
|
|
|
|
|
configHash: function(webpackConfig) {
|
|
|
|
|
// node-object-hash on npm can be used to build this.
|
|
|
|
|
return require('node-object-hash')({sort: false}).hash(webpackConfig);
|
|
|
|
|
},
|
|
|
|
|
// 当加载器,插件,其他构建时脚本或其他动态依赖项发生更改时,hard-source需要替换缓存以确保输
|
|
|
|
|
// 出正确。environmentHash被用来确定这一点。如果散列与先前的构建不同,则将使用新的缓存
|
|
|
|
|
environmentHash: {
|
|
|
|
|
root: process.cwd(),
|
|
|
|
|
directories: [],
|
|
|
|
|
files: ['package-lock.json', 'yarn.lock'],
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
// Some libraries import Node modules but don't use them in the browser.
|
|
|
|
|
// Tell Webpack to provide empty mocks for them so importing them works.
|
|
|
|
|