Skip to content
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

Merged
merged 11 commits into from Apr 18, 2019
Merged

feat: enable contenthash for assets #161

merged 11 commits into from Apr 18, 2019

Conversation

ahungrynoob
Copy link
Contributor

@ahungrynoob ahungrynoob commented Mar 22, 2019

Checklist

  • npm test passes
  • tests are included
  • documentation is changed or added
  • commit message follows commit guidelines

Affected plugin(s)

beidou-webpack, beidou-view, beidou-view-react, beidou-view-rax

Description of change

#55

@codecov-io
Copy link

codecov-io commented Mar 22, 2019

Codecov Report

Merging #161 into master will increase coverage by 0.19%.
The diff coverage is 100%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...es/beidou-webpack/config/webpack/webpack.common.js 100% <100%> (ø) ⬆️
packages/beidou-view/config/config.default.js 100% <100%> (ø)
packages/beidou-view/lib/utils.js 95% <100%> (+2.14%) ⬆️
packages/beidou-view/app/extend/helper.js 100% <100%> (ø) ⬆️
...s/beidou-webpack/config/webpack/webpack.browser.js 100% <100%> (ø) ⬆️
packages/beidou-view/app.js 100% <100%> (ø)
packages/beidou-view-rax/lib/rax-view.js 94.11% <0%> (-5.89%) ⬇️
packages/beidou-webpack/config/webpack/utils.js 94.73% <0%> (+5.26%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bd4bd56...f886ba6. Read the comment docs.

@justquanyin
Copy link
Collaborator

用来解决webpack打包hash资源命名的问题?

@@ -21,6 +21,7 @@ module.exports = appInfo => ({
assetPath: '/build/',
},
view: {
useHashAsset: false,
Copy link
Collaborator

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')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里还是不要默认使用hash的方式抽离css文件了

app.config.view.useHashAsset = false;
return;
}
app.assetManifest = getAssetManifest(app.baseDir);
Copy link
Collaborator

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') },
Copy link
Collaborator

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,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@ahungrynoob
Copy link
Contributor Author

好的 我有空优化下

@@ -147,7 +147,7 @@ e.g.:
{
webpack: {
custom: {
proxy: '/foo*'
proxy: '/foo*';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

去掉";"

Copy link
Contributor Author

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

判断条件: viewConfig && viewConfig.useHashAsset && !dev

justquanyin
justquanyin previously approved these changes Apr 3, 2019
@njugray njugray merged commit b2fdb07 into alibaba:master Apr 18, 2019
@ahungrynoob ahungrynoob deleted the feat-enable-contenthash branch May 9, 2019 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants