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: add helmet plugin #180

Merged
merged 23 commits into from
May 19, 2020
Merged

feat: add helmet plugin #180

merged 23 commits into from
May 19, 2020

Conversation

ycjcl868
Copy link
Contributor

@ycjcl868 ycjcl868 commented Apr 27, 2020

Usage: yarn add @umijs/plugin-helmet,考虑内置到 @umijs/preset-react 中,不需要单独再安装

import { Helmet } from 'umi';


export default function() {
  return (
    <>
      <Helmet>
        <title>Title Helmet</title>
      </Helmet>
    </>
  );
}

normal: <title>Title Helmet</title>

if SSR:
=> <title data-rh=\"true\">Title Helmet</title>

@ycjcl868 ycjcl868 mentioned this pull request Apr 27, 2020
4 tasks
@codecov
Copy link

codecov bot commented Apr 27, 2020

Codecov Report

Merging #180 into master will increase coverage by 0.33%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #180      +/-   ##
==========================================
+ Coverage   51.48%   51.81%   +0.33%     
==========================================
  Files          65       66       +1     
  Lines        1447     1457      +10     
  Branches      404      404              
==========================================
+ Hits          745      755      +10     
  Misses        702      702              
Impacted Files Coverage Δ
packages/preset-react/src/index.ts 0.00% <ø> (ø)
packages/plugin-helmet/src/index.ts 100.00% <100.00%> (ø)

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 984579e...97e4bf4. Read the comment docs.

@ycjcl868 ycjcl868 added the enhancement New feature or request label Apr 28, 2020
@ycjcl868 ycjcl868 mentioned this pull request Apr 30, 2020
60 tasks
@sorrycc
Copy link
Member

sorrycc commented May 13, 2020

ssr 依赖这个插件才能正常生成 title 等 head 信息?那应该内置在 umi 里啊。

@ycjcl868
Copy link
Contributor Author

ycjcl868 commented May 13, 2020

ssr 依赖这个插件才能正常生成 title 等 head 信息?那应该内置在 umi 里啊。

不需要依赖也可以,就是走 title 配置

@sorrycc
Copy link
Member

sorrycc commented May 13, 2020

验证下只是开启这个插件,但是不使用,打包会不会包含 helmt 脚本,也就是会不会被 tree-shaking 掉。

@ycjcl868
Copy link
Contributor Author

验证下只是开启这个插件,但是不使用,打包会不会包含 helmt 脚本,也就是会不会被 tree-shaking 掉。

验证了,这样就不会打包到 umi.js 中了 97e4bf4

@sorrycc sorrycc merged commit 70ffc80 into master May 19, 2020
@delete-merged-branch delete-merged-branch bot deleted the feat-helmet-plugin branch May 19, 2020 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants