mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-05 19:41:57 +08:00
feat: 添加plugin-hardSource,增加dev时的构建速度
This commit is contained in:
parent
1da8718198
commit
89130e672a
@ -37,6 +37,7 @@
|
||||
"html-webpack-tags-plugin": "2.0.17",
|
||||
"vue-loader": "^16.1.2",
|
||||
"webpack-bundle-analyzer": "4.3.0",
|
||||
"babel-plugin-import": "1.13.3"
|
||||
"babel-plugin-import": "1.13.3",
|
||||
"hard-source-webpack-plugin": "0.13.1"
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ export default function () {
|
||||
require.resolve('./plugins/features/targets'),
|
||||
require.resolve('./plugins/features/terserOptions'),
|
||||
require.resolve('./plugins/features/vueLoader'),
|
||||
require.resolve('./plugins/features/hardSource'),
|
||||
|
||||
// misc
|
||||
require.resolve('./plugins/misc/route'),
|
||||
|
@ -0,0 +1,43 @@
|
||||
import {
|
||||
winPath
|
||||
} from '@umijs/utils';
|
||||
import HardSourceWebpackPlugin from 'hard-source-webpack-plugin';
|
||||
|
||||
export default (api) => {
|
||||
api.describe({
|
||||
key: 'hardSource',
|
||||
config: {
|
||||
schema(joi) {
|
||||
return joi.object();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
api.chainWebpack((webpackConfig) => {
|
||||
const cwd = api.cwd;
|
||||
if (api.env === 'development') {
|
||||
webpackConfig
|
||||
.plugin('hardSource')
|
||||
.use(HardSourceWebpackPlugin, [{
|
||||
cacheDirectory: winPath(`${cwd}/.cache/hard-source/[confighash]`),
|
||||
...api.config.hardSource || {}
|
||||
}]);
|
||||
webpackConfig
|
||||
.plugin('hardSourceExclude')
|
||||
.use(HardSourceWebpackPlugin.ExcludeModulePlugin, [
|
||||
[
|
||||
{
|
||||
// HardSource works with mini-css-extract-plugin but due to how
|
||||
// mini-css emits assets, assets are not emitted on repeated builds with
|
||||
// mini-css and hard-source together. Ignoring the mini-css loader
|
||||
// modules, but not the other css loader modules, excludes the modules
|
||||
// that mini-css needs rebuilt to output assets every time.
|
||||
test: /mini-css-extract-plugin[\\/]dist[\\/]loader/
|
||||
}
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
return webpackConfig;
|
||||
});
|
||||
};
|
30
yarn.lock
30
yarn.lock
@ -9271,6 +9271,25 @@ hard-rejection@^2.1.0:
|
||||
resolved "https://registry.npmjs.org/hard-rejection/-/hard-rejection-2.1.0.tgz#1c6eda5c1685c63942766d79bb40ae773cecd883"
|
||||
integrity sha512-VIZB+ibDhx7ObhAe7OVtoEbuP4h/MuOTHJ+J8h/eBXotJYl0fBgR72xDFCKgIh22OJZIOVNxBMWuhAr10r8HdA==
|
||||
|
||||
hard-source-webpack-plugin@^0.13.1:
|
||||
version "0.13.1"
|
||||
resolved "https://registry.yarnpkg.com/hard-source-webpack-plugin/-/hard-source-webpack-plugin-0.13.1.tgz#a99071e25b232f1438a5bc3c99f10a3869e4428e"
|
||||
integrity sha512-r9zf5Wq7IqJHdVAQsZ4OP+dcUSvoHqDMxJlIzaE2J0TZWn3UjMMrHqwDHR8Jr/pzPfG7XxSe36E7Y8QGNdtuAw==
|
||||
dependencies:
|
||||
chalk "^2.4.1"
|
||||
find-cache-dir "^2.0.0"
|
||||
graceful-fs "^4.1.11"
|
||||
lodash "^4.15.0"
|
||||
mkdirp "^0.5.1"
|
||||
node-object-hash "^1.2.0"
|
||||
parse-json "^4.0.0"
|
||||
pkg-dir "^3.0.0"
|
||||
rimraf "^2.6.2"
|
||||
semver "^5.6.0"
|
||||
tapable "^1.0.0-beta.5"
|
||||
webpack-sources "^1.0.1"
|
||||
write-json-file "^2.3.0"
|
||||
|
||||
has-ansi@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
|
||||
@ -11949,6 +11968,11 @@ node-modules-regexp@^1.0.0:
|
||||
resolved "https://registry.npmjs.org/node-modules-regexp/-/node-modules-regexp-1.0.0.tgz#8d9dbe28964a4ac5712e9131642107c71e90ec40"
|
||||
integrity sha1-jZ2+KJZKSsVxLpExZCEHxx6Q7EA=
|
||||
|
||||
node-object-hash@^1.2.0:
|
||||
version "1.4.2"
|
||||
resolved "https://registry.yarnpkg.com/node-object-hash/-/node-object-hash-1.4.2.tgz#385833d85b229902b75826224f6077be969a9e94"
|
||||
integrity sha512-UdS4swXs85fCGWWf6t6DMGgpN/vnlKeSGEQ7hJcrs7PBFoxoKLmibc3QRb7fwiYsjdL7PX8iI/TMSlZ90dgHhQ==
|
||||
|
||||
node-releases@^1.1.61:
|
||||
version "1.1.65"
|
||||
resolved "https://registry.npmjs.org/node-releases/-/node-releases-1.1.65.tgz#52d9579176bd60f23eba05c4438583f341944b81"
|
||||
@ -15734,7 +15758,7 @@ table@^6.0.4:
|
||||
slice-ansi "^4.0.0"
|
||||
string-width "^4.2.0"
|
||||
|
||||
tapable@1.1.3, tapable@^1.0.0, tapable@^1.1.3:
|
||||
tapable@1.1.3, tapable@^1.0.0, tapable@^1.0.0-beta.5, tapable@^1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.npmjs.org/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2"
|
||||
integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==
|
||||
@ -16892,7 +16916,7 @@ webpack-merge@^5.7.3:
|
||||
clone-deep "^4.0.1"
|
||||
wildcard "^2.0.0"
|
||||
|
||||
webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3:
|
||||
webpack-sources@^1.0.1, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3:
|
||||
version "1.4.3"
|
||||
resolved "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933"
|
||||
integrity sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ==
|
||||
@ -17295,7 +17319,7 @@ write-file-atomic@^2.0.0, write-file-atomic@^2.3.0, write-file-atomic@^2.4.2:
|
||||
imurmurhash "^0.1.4"
|
||||
signal-exit "^3.0.2"
|
||||
|
||||
write-json-file@^2.2.0:
|
||||
write-json-file@^2.2.0, write-json-file@^2.3.0:
|
||||
version "2.3.0"
|
||||
resolved "https://registry.npmjs.org/write-json-file/-/write-json-file-2.3.0.tgz#2b64c8a33004d54b8698c76d585a77ceb61da32f"
|
||||
integrity sha1-K2TIozAE1UuGmMdtWFp3zrYdoy8=
|
||||
|
Loading…
x
Reference in New Issue
Block a user