-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: enable contenthash for assets #161
Conversation
Codecov Report
@@ Coverage Diff @@
## master #161 +/- ##
==========================================
+ Coverage 92.89% 93.09% +0.19%
==========================================
Files 86 88 +2
Lines 1563 1593 +30
==========================================
+ Hits 1452 1483 +31
+ Misses 111 110 -1
Continue to review full report at Codecov.
|
用来解决webpack打包hash资源命名的问题? |
@@ -21,6 +21,7 @@ module.exports = appInfo => ({ | |||
assetPath: '/build/', | |||
}, | |||
view: { | |||
useHashAsset: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个配置是在beidou-view的插件下用的,最好放在beidou-view的配置下
@@ -48,7 +48,7 @@ module.exports = (app, entry, dev) => { | |||
}); | |||
|
|||
factory | |||
.definePlugin(ExtractTextPlugin, '[name].css', 'ExtractTextPlugin') | |||
.definePlugin(ExtractTextPlugin, '[name]_[md5:contenthash:hex:8].css', 'ExtractTextPlugin') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里还是不要默认使用hash的方式抽离css文件了
packages/beidou-view/app.js
Outdated
app.config.view.useHashAsset = false; | ||
return; | ||
} | ||
app.assetManifest = getAssetManifest(app.baseDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
获取mapping资源文件最好可配置
@@ -92,5 +94,17 @@ module.exports = (app, entry, dev) => { | |||
'HotModuleReplacementPlugin' | |||
); | |||
} | |||
if (reservedConfig.assetWithHash && !dev) { | |||
factory.addPlugin(ManifestPlugin, | |||
{ fileName: path.join(app.baseDir, 'manifest.json') }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapping资源路径最好可配置资源路径。
可参考beidou-isomophic 和 beidou-webpack的共用配置,如不存在这个配置,可使用默认值。
建议是不是也可以看看 assetWithHash也共用一个配置
@@ -31,6 +31,7 @@ module.exports = (appInfo) => { | |||
placeHolder: '<!--$render$-->', | |||
}, | |||
view: { | |||
useHashAsset: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
好的 我有空优化下 |
packages/beidou-webpack/README.md
Outdated
@@ -147,7 +147,7 @@ e.g.: | |||
{ | |||
webpack: { | |||
custom: { | |||
proxy: '/foo*' | |||
proxy: '/foo*'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
去掉";"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这是prettier自己加的- -
@@ -92,5 +93,17 @@ module.exports = (app, entry, dev) => { | |||
'HotModuleReplacementPlugin' | |||
); | |||
} | |||
if (viewConfig.useHashAsset && !dev) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
判断条件: viewConfig && viewConfig.useHashAsset && !dev
Checklist
npm test
passesAffected plugin(s)
beidou-webpack, beidou-view, beidou-view-react, beidou-view-rax
Description of change
#55