<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jacky Tung on Medium]]></title>
        <description><![CDATA[Stories by Jacky Tung on Medium]]></description>
        <link>https://medium.com/@Jacky_Tung?source=rss-2bf67786a78d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*mwBdAl_XW8_YKjvp</url>
            <title>Stories by Jacky Tung on Medium</title>
            <link>https://medium.com/@Jacky_Tung?source=rss-2bf67786a78d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:09:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@Jacky_Tung/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Talk about large React project structure]]></title>
            <link>https://medium.com/htc-research-engineering-blog/talk-about-large-react-project-structure-9ebb321d51df?source=rss-2bf67786a78d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ebb321d51df</guid>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Jacky Tung]]></dc:creator>
            <pubDate>Sun, 02 Feb 2020 08:45:12 GMT</pubDate>
            <atom:updated>2020-02-02T08:45:12.698Z</atom:updated>
            <content:encoded><![CDATA[<p>I dedicated to the web-development fields for 2 years. I remember when I start to learn front-end skill, the most struggle stuff to me is project structure design. This article, I will share our team experience on project structure design. (Note: It’s not the Best Practice, the project structure depends on your scenario)</p><p>When we kick-off a project, we want project including following things:</p><ol><li>follow create-react-app, avoid to use webpack (it’s to complicated)</li><li>easy-managed router (react-router)</li><li>code splitting based on different components, only loads necessary js file. (react-loadable)</li><li>easy-managed states, keep all data from the same source. (redux)</li><li>separate UI logic, data select logic (reselect) and data fetching logic.</li><li>handle async actions (redux-observable).</li><li>use third-party design system (material-UI)</li><li>support i18n (react-i18next)</li><li>consistent coding style (eslint, prettier)</li></ol><h4>react-loadable</h4><p>We want our web application serve as many features as possible. The more features we have, the larger codebase we need to handle. It is reasonable to expect the performance of web application will dwindle. Code splitting is a technique where an application only loads the necessary code. It’s doable in React by using <a href="https://github.com/jamiebuilds/react-loadable">react-loadable</a>. React-loadable is a higher order component for loading components with dynamic imports.</p><p>Following is using an ordering system for example, if users want to order something, application only loads order-related components. And if users want to check profile in account page, application only loads account-related components.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/361739badc4ffae54a8e1809596d7971/href">https://medium.com/media/361739badc4ffae54a8e1809596d7971/href</a></iframe><h4>Separate logic for UI, data selection, data fetching, states</h4><p>Separate logic can help developer maintain project more easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3GiKpn8MIWsetDXPOSpxw.png" /><figcaption>our data flow</figcaption></figure><p>Responsibilities of each component:</p><ul><li>View: UI logic only, dispatch actions (e.g. fetchProfile), and get states from selectors.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a65227d65a30c5c31cb6cb2c1d991ecf/href">https://medium.com/media/a65227d65a30c5c31cb6cb2c1d991ecf/href</a></iframe><ul><li>Action: define action name</li><li>Middleware: handle async event (e.g. call API)</li><li>Reducer: store data from API result, let data structure as consistent with database as possible.</li></ul><p>We use <a href="https://redux-toolkit.js.org/">redux-toolkit</a> to let develop redux component more easier. Using createSlice functions can automatically generates action creator functions, action type strings, and a reducer function. (you can check <a href="https://redux-toolkit.js.org/tutorials/basic-tutorial">basic tutorial</a> for redux toolkit)</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08265c8e0ef3872e274761f7c5fa0cde/href">https://medium.com/media/08265c8e0ef3872e274761f7c5fa0cde/href</a></iframe><ul><li>Selector: select data from store, let data structure as consistent with UI logic as possible.</li></ul><p>We use <a href="https://github.com/reduxjs/reselect">reselect library</a> to select data from store because it is efficient, composable, and allowing Redux to store the minimal possible state. (The official page of reselect library already detailed introduce. It’s no need to show example here)</p><h4>Third party designed system — Material UI</h4><p>Following are the reasons why we use <a href="https://material-ui.com/">material-ui</a>.</p><ul><li>Based on Google Material Design. The guideline is easy to follow. It’s good for both developers and designers.</li><li>Well document and have many examples</li><li>Allow responsive UI</li><li>Customize, you can create your own theme.</li></ul><p>After everything set up, the folder structure will look like:</p><pre>- apis/          // api definitions<br>- components/    // UI logic and data select logic<br>- containers/    // setup router and react-loadable<br>- features/      // data fetching logic, states logic<br>- redux/         // setup middleware, reducer and store<br>- styles/        // setup global styles<br>- utils/         // setup common functions<br>- index.js<br>- App.js</pre><p>You can reference example from <a href="https://github.com/JackyTung/my-react-app">here</a>. I hope above sharing can help you to focus on UI logic and Business logic implementation. Thanks for your reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ebb321d51df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/htc-research-engineering-blog/talk-about-large-react-project-structure-9ebb321d51df">Talk about large React project structure</a> was originally published in <a href="https://medium.com/htc-research-engineering-blog">DeepQ Research Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The SEO discover for Vuejs]]></title>
            <link>https://medium.com/htc-research-engineering-blog/the-seo-discover-for-vuejs-46c11a837a11?source=rss-2bf67786a78d------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c11a837a11</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[vuejs]]></category>
            <dc:creator><![CDATA[Jacky Tung]]></dc:creator>
            <pubDate>Thu, 05 Jul 2018 08:05:40 GMT</pubDate>
            <atom:updated>2018-07-05T08:05:40.045Z</atom:updated>
            <content:encoded><![CDATA[<p>SEO is a indispensable part for websites. A good SEO can help website to be indexed easily by search engine. My website is built by Vuejs and hosting on firebase. In this article, I will share the SEO experience on:<br>1. sitemap<br>2. custom 404 page<br>3. facebook open graph<br>4. asset cache ability</p><p>If you are interesting in other SEO topics, you can check:</p><ul><li><a href="https://www.woorank.com/en/edu/seo-guides">SEO Guides</a></li><li><a href="https://medium.com/htc-research-engineering-blog/seo-search-engine-optimization-discover-9c360619d986">SEO (search engine optimization) Discover</a></li></ul><h3>Sitemap</h3><p>Sitemap can help search engines to know which pages are important and relevant on site. However, search engine can’t recognize sitemap which includes # links. Therefore, I suggest to use vue-router <strong>history mode</strong> to develop web application.</p><pre>const router = new VueRouter({<br>  mode: &#39;history&#39;,<br>  routes: [...]<br>})</pre><p>To generate the sitemap.xml, we use the <a href="https://www.npmjs.com/package/sitemap-webpack-plugin"><strong>sitemap webpack plugin</strong></a></p><pre>// webpack.config.prod.js</pre><pre>const SitemapPlugin = require(&#39;sitemap-webpack-plugin&#39;).default;<br>const prettydata = require(&#39;pretty-data&#39;);<br>const merge = require(&#39;webpack-merge&#39;);<br>const baseWebpackConfig = require(&#39;./webpack.config.base&#39;);</pre><pre>const paths = [<br>  &#39;/&#39;<br>  &#39;/docs&#39;,<br>  &#39;/pricing&#39;,<br>  &#39;/about&#39;<br>]</pre><pre>const prettyPrint = xml =&gt; {<br>  const result = prettydata.pd.xml(xml);<br>  return result;<br>};</pre><pre>const config = merge(baseWebpackConfig, {<br>  mode: &#39;production&#39;,<br>  plugins: [<br>    new SitemapPlugin(&#39;https://my.website.com/&#39;, paths, {<br>      changeFreq: &#39;monthly&#39;,<br>      skipGzip: true,<br>      formatter: prettyPrint,<br>    }),<br>  ],<br>});</pre><p>After deploying the sitemap, we can go to <a href="https://www.google.com/webmasters/tools/home"><strong>search console</strong></a> to add the sitemap reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0xT87d4dvEhj_IAKxHIeeQ.png" /><figcaption>add sitemap in search console</figcaption></figure><p>If your sitemap can’t be indexed successfully, goto <strong><em>Crawl → Crawl Errors</em></strong> to see the detail messages and use <strong><em>Fetch as Google</em></strong> to check whether the page is rendered successfully or not.</p><h3>Custom 404 page</h3><p>If user try to visit the none-exist url of website, we should give user a custom 404 page. It can reduce user frustration and help user to find out which part they can visit on website. ( reference: <a href="https://www.woorank.com/en/blog/takeaways-from-great-404-error-pages">Great 404 error pages</a>)</p><p><strong>Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uMOFc7I5UV7xztuinpj9xA.png" /><figcaption>Airbnb — custom 404 page</figcaption></figure><p><strong>Implementation:</strong></p><p>Using vue-router history mode only handle 1 case for 404 not found page. (e.g. <a href="https://mysite.com/page/not/found).">https://mysite.com/page/not/found).</a> When we set the vue-router to history mode, we should catch-all fallback route to server. Here is the example for firebase hosting configuration:</p><pre>// firebase.json</pre><pre>{<br>  &quot;hosting&quot;: {<br>    &quot;public&quot;: &quot;dist&quot;,<br>    &quot;rewrites&quot;: [<br>      {<br>        &quot;source&quot;: &quot;**&quot;,<br>        &quot;destination&quot;: &quot;/index.html&quot;<br>      }<br>    ]<br>  }<br>}</pre><p><strong>Bue, how to catch-all fallback in development </strong>?</p><p>we use the <a href="https://webpack.js.org/configuration/dev-server/#devserver-historyapifallback"><strong>devSer.historyApiFallback</strong></a> to configure webpack file.</p><pre>// webpack.config.dev.js</pre><pre>const config = merge(baseWebpackConfig, {<br>  mode: &#39;development&#39;,<br>  devServer: {<br>    contentBase: path.join(__dirname, &#39;static&#39;),<br>    historyApiFallback: {<br>      index: &#39;/your-public-path/&#39;<br>    }<br>  }<br>});</pre><p>Now, we can implement a catch-all route to show a 404 page.</p><pre>const router = new VueRouter({<br>  mode: &#39;history&#39;,<br>  routes: [<br>    { path: &#39;*&#39;, component: NotFoundComponent }<br>  ]<br>})</pre><h3>Facebook Open Graph</h3><p>Facebook Open Graph can enrich website content when we sharing the link on social medias. ( use <a href="https://developers.facebook.com/tools/debug/">Facebook debug tool</a> to verify after adding the meta tags.)</p><pre>&lt;meta property=&quot;og:site_name&quot; content=&quot;My Website&quot;/&gt;<br>&lt;meta property=&quot;og:type&quot; content=&quot;article&quot;/&gt;<br>&lt;meta property=&quot;og:title&quot; content=&quot;my website title&quot;/&gt;<br>&lt;meta property=&quot;og:url&quot; content=&quot;https://my.website.com/&quot;&gt;<br>&lt;meta property=&quot;og:description&quot; content=&quot;my website description&quot;/&gt;<br>&lt;meta property=&quot;og:image&quot; content=&quot;https://my.storage/image.png&quot;/&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*yaw1EleYVtsH-mD4ZQDVoA.png" /><figcaption>Evernote — preview on social network</figcaption></figure><p>Ideally, we want to add different meta tags to each page. However, Vuejs is Single Page Application (SPA), which means all links are handled by single route. The crawler don’t run our Javascript to find the meta data. Therefore, we need to simulate the static HTML files for each route.</p><p>There are two common approaches to solve SPA problems</p><ol><li>Prerendering</li><li><a href="https://ssr.vuejs.org/">Server-Side Rendering</a></li></ol><p>Prerendering is a methods to generate static HTML files to each route at build time. It’s a simpler solution than Server-Side Rendering. Following is the example webpack configurations which use <a href="https://github.com/chrisvfritz/prerender-spa-plugin">prerender-spa-plugin</a>.</p><pre>// webpack.config.prod.js</pre><pre>const config = merge(baseWebpackConfig, {<br>  mode: &#39;production&#39;,<br>  ....<br>  plugins: [<br>     new PrerenderSPAPlugin({<br>       staticDir: path.resolve(__dirname, &#39;dist/&#39;),<br>       routes: [&#39;/&#39;, &#39;/about&#39;, &#39;/docs&#39;],<br>       postProcess(context) {<br>          context.path = context.originalPath;<br>          const titles = {<br>            &#39;/&#39;: &#39;My Website&#39;,<br>            &#39;/about&#39;: &#39;DeepQ AI Platform - About&#39;,<br>            &#39;/docs&#39;: &#39;DeepQ AI Platform - Docs&#39;,<br>          };<br>          const desc = {<br>            &#39;/&#39;: &#39;Home Page Descriptions&#39;,<br>            &#39;/about&#39;: &#39;About Page Descriptions&#39;,<br>            &#39;/docs&#39;: &#39;Docs Page Descriptions&#39;,<br>          };</pre><pre>          context.html = context.html.replace(<br>            /&lt;title&gt;[^&lt;]*&lt;\/title&gt;/i,<br>            &#39;&lt;title&gt;&#39; + titles[context.route] + &#39;&lt;/title&gt;&lt;meta name=&quot;description&quot; content=&quot;&#39;+desc[context.route]+&#39;&quot;&gt;&#39;<br>          );<br>          return context;<br>       },<br>     }),<br>   ],<br>});</pre><p>Although prerender-spa-plugin is easy to use, it’s not perfect. It can’t support multi-language. It’s hard to maintain when website has a large amount of routes.</p><h3>Browser Caching</h3><p>Consider the web performance and user experience, we don’t want user download assets every time. Therefore, we need to set cache to static files.</p><pre>// firebase.json</pre><pre>&quot;headers&quot;: [ {<br>  &quot;source&quot; : &quot;**/*.@(jpg|jpeg|gif|png)&quot;,<br>  &quot;headers&quot; : [ {<br>    &quot;key&quot; : &quot;Cache-Control&quot;,<br>    &quot;value&quot; : &quot;max-age=7200&quot;<br>  } ]<br>}, {<br>  // Sets the cache header for 404 pages to cache for 5 minutes<br>  &quot;source&quot; : &quot;404.html&quot;,<br>  &quot;headers&quot; : [ {<br>    &quot;key&quot; : &quot;Cache-Control&quot;,<br>    &quot;value&quot; : &quot;max-age=300&quot;<br>  } ]<br>} ]</pre><h3>Summary</h3><p>In conclusion, for a vue developer to do SEO I will suggest:</p><ol><li>vue-router use history mode</li></ol><ul><li>let sitemap.xml can be indexed by google search engine</li><li>handle the single case for 404 not found page <br>( in hash mode, you need to handle <em>https://mysite.com/page/not/found/#</em> and <em>https://mysite.com/#/page/not/found</em>)</li></ul><p>2. If your website is a static or small website, I recommend to use prerender-spa-plugin to add meta-tags to each route.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=46c11a837a11" width="1" height="1" alt=""><hr><p><a href="https://medium.com/htc-research-engineering-blog/the-seo-discover-for-vuejs-46c11a837a11">The SEO discover for Vuejs</a> was originally published in <a href="https://medium.com/htc-research-engineering-blog">DeepQ Research Engineering Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>