Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit79a6d43

Browse files
authored
build(reduice-size): globally (#1130)
* chore: add local svg icons* chore: use local svgs* build(size): reduce size by rm i18n && dynamic load* build(size): reduce size by rm i18n && dynamic load* build(size): reduce size by rm i18n && dynamic load* chore: reduce build size wip* chore: reduce build size wip* build(size): reduce size wip* chore: remove un-used container* chore: test dynamic waypoint tracker* chore: move waypoint load to client* build(size): fix crash* build(size): remove unused part* build(size): drop sentry support* chore: trigger ci
1 parentf9636bf commit79a6d43

File tree

215 files changed

+1556
-4463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

215 files changed

+1556
-4463
lines changed

‎.eslintrc.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ module.exports = {
3232
'@/schemas':'src/schemas',
3333
'@/Img':'src/components/Img',
3434
'@/SvgIcons':'src/components/SvgIcons',
35+
'@/icons':'src/components/Icons',
3536
'@/i18n':'i18n',
3637
'@/spec':'src/spec',
3738
},
@@ -40,6 +41,7 @@ module.exports = {
4041
},
4142
},
4243
rules:{
44+
'@typescript-eslint/no-var-requires':0,
4345
'@typescript-eslint/ban-ts-comment':0,
4446
'react/jsx-uses-react':'off',
4547
'react/react-in-jsx-scope':'off',

‎jsconfig.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@/schemas": ["src/schemas"],
1717
"@/Img": ["src/components/Img"],
1818
"@/SvgIcons/*": ["src/components/SvgIcons/*"],
19+
"@/icons/*": ["src/components/icons/*"],
1920
"@/i18n": ["i18n"]
2021
}
2122
},

‎next.config.docker.js‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ const nextConfig = {
2424
'process.env.SENTRY_RELEASE':JSON.stringify(buildId),
2525
}),
2626
)
27-
if(!isServer){
28-
config.resolve.alias['@sentry/node']='@sentry/browser'
29-
}
3027

3128
returnconfig
3229
},

‎next.config.js‎

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
1010
constofflineConfig=require('./config/next_offline')
1111

1212
// Use the SentryWebpack plugin to upload the source maps during build step
13-
constSentryWebpackPlugin=require('@sentry/webpack-plugin')
13+
//const SentryWebpackPlugin = require('@sentry/webpack-plugin')
1414

15-
const{
16-
NEXT_PUBLIC_SENTRY_DSN:SENTRY_DSN,
17-
SENTRY_ORG,
18-
SENTRY_PROJECT,
19-
SENTRY_AUTH_TOKEN,
20-
NODE_ENV,
21-
}=process.env
15+
//const {
16+
// NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
17+
// SENTRY_ORG,
18+
// SENTRY_PROJECT,
19+
// SENTRY_AUTH_TOKEN,
20+
// NODE_ENV,
21+
//} = process.env
2222

23-
process.env.SENTRY_DSN=SENTRY_DSN
23+
//process.env.SENTRY_DSN = SENTRY_DSN
2424

2525
// next-plugins end
2626

@@ -34,38 +34,6 @@ const nextConfig = {
3434
newwebpack.ContextReplacementPlugin(/moment[/\\]locale$/,/(en)/),
3535
)
3636

37-
// for sentry
38-
config.plugins.push(
39-
newwebpack.DefinePlugin({
40-
'process.env.SENTRY_RELEASE':JSON.stringify(buildId),
41-
}),
42-
)
43-
if(!isServer){
44-
config.resolve.alias['@sentry/node']='@sentry/browser'
45-
}
46-
47-
// When all the Sentry configuration env variables are available/configured
48-
// The Sentry webpack plugin gets pushed to the webpack plugins to build
49-
// and upload the source maps to sentry.
50-
// This is an alternative to manually uploading the source maps
51-
// Note: This is disabled in development mode.
52-
if(
53-
SENTRY_DSN&&
54-
SENTRY_ORG&&
55-
SENTRY_PROJECT&&
56-
SENTRY_AUTH_TOKEN&&
57-
NODE_ENV==='production'
58-
){
59-
config.plugins.push(
60-
newSentryWebpackPlugin({
61-
include:'.next',
62-
ignore:['node_modules'],
63-
urlPrefix:'~/_next',
64-
release:buildId,
65-
}),
66-
)
67-
}
68-
6937
returnconfig
7038
},
7139
}

‎package.json‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"graphql-voyager":"^1.0.0-rc.31",
8585
"js-cookie":"^2.2.0",
8686
"mastani-codehighlight":"0.0.7",
87-
"mobile-device-detect":"^0.4.3",
8887
"mobx":"6.3.2",
8988
"mobx-react":"7.2.0",
9089
"mobx-react-lite":"3.2.0",
@@ -95,7 +94,6 @@
9594
"next-compose-plugins":"^2.2.0",
9695
"next-i18next":"4.4.1",
9796
"next-offline":"4.0.6",
98-
"next-seo":"4.4.0",
9997
"nextjs-progressbar":"^0.0.6",
10098
"overlayscrollbars":"1.13.1",
10199
"path-match":"^1.2.4",
@@ -110,6 +108,7 @@
110108
"react-calendar-heatmap":"1.8.1",
111109
"react-content-loader":"3.4.2",
112110
"react-copy-to-clipboard":"^5.0.3",
111+
"react-device-detect":"^1.17.0",
113112
"react-dom":"17.0.2",
114113
"react-highlight-words":"^0.16.0",
115114
"react-lazy-load-image-component":"1.5.0",

‎server/index.js‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-var-requires */
12
/**
23
*
34
* this server is only used for next.js SSR
@@ -13,8 +14,8 @@ const mobxReact = require('mobx-react')
1314
// inspect graphql model
1415
const{express:voyagerMiddleware}=require('graphql-voyager/middleware')
1516
// i18n setup
16-
constnextI18NextMiddleware=require('next-i18next/middleware').default
17-
constnextI18next=require('../i18n')
17+
//const nextI18NextMiddleware = require('next-i18next/middleware').default
18+
//const nextI18next = require('../i18n')
1819

1920
constapp=require('./app')
2021
const{ redirectToNakedUrl}=require('./helper')
@@ -44,8 +45,8 @@ mobxReact.enableStaticRendering(true)
4445
voyagerMiddleware({endpointUrl:CONFIG.GRAPHQL_ENDPOINT}),
4546
)
4647

47-
awaitnextI18next.initPromise
48-
server.use(nextI18NextMiddleware(nextI18next))
48+
//await nextI18next.initPromise
49+
//server.use(nextI18NextMiddleware(nextI18next))
4950

5051
// eslint-disable-next-line global-require
5152
server.use('/',require('./routes'))

‎src/components/ArticleBaseStats/index.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import{FC,memo}from'react'
88

99
importtype{TArticle,TContainer}from'@/spec'
10-
import{ICON}from'@/config'
1110
import{buildLog,scrollToComments}from'@/utils'
1211

1312
import{Space}from'@/components/Common'
@@ -36,11 +35,11 @@ const ArticleBaseStats: FC<TProps> = ({
3635
})=>{
3736
return(
3837
<Wrappertestid={testid}>
39-
<ViewsIconsrc={`${ICON}/article/viewed.svg`}/>
38+
<ViewsIcon/>
4039
<Count>{article.views}</Count>
4140
<Spaceleft={14}/>
4241
<CommentWrapperonClick={()=>scrollToComments(container)}>
43-
<CommentIconsrc={`${ICON}/article/comment.svg`}/>
42+
<CommentIcon/>
4443
<CommentCount>{article.commentsCount}</CommentCount>
4544
</CommentWrapper>
4645
</Wrapper>

‎src/components/ArticleBaseStats/styles/index.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@ import styled from 'styled-components'
22

33
importtype{TTestable}from'@/spec'
44

5-
importImgfrom'@/Img'
5+
importViewSVGIconfrom'@/icons/View'
6+
importCommentSVGIconfrom'@/icons/Comment'
7+
68
import{css,theme}from'@/utils'
79

810
exportconstWrapper=styled.div.attrs(({ testid}:TTestable)=>({
911
'data-test-id':testid,
1012
}))<TTestable>`
1113
${css.flex('align-center')};
1214
`
13-
constIcon=styled(Img)`
15+
exportconstViewsIcon=styled(ViewSVGIcon)`
1416
fill:${theme('thread.articleDigest')};
1517
${css.size(14)};
1618
transition: fill 0.25s;
1719
`
18-
exportconstViewsIcon=styled(Icon)``
19-
2020
exportconstCommentWrapper=styled.div`
2121
${css.flex('align-center')};
2222
`
23-
exportconstCommentIcon=styled(Icon)`
23+
exportconstCommentIcon=styled(CommentSVGIcon)`
24+
fill:${theme('thread.articleDigest')};
25+
${css.size(14)};
26+
transition: fill 0.25s;
27+
2428
${CommentWrapper}:hover & {
2529
cursor: pointer;
2630
fill:${theme('thread.articleTitle')};

‎src/components/ArticlesFilter/DesktopView.tsx‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import dynamic from 'next/dynamic'
99

1010
importtype{TArticleFilter,TResState}from'@/spec'
1111

12-
import{TYPE}from'@/constant'
12+
import{TYPE,THREAD}from'@/constant'
1313
import{buildLog}from'@/utils'
14-
import{useViewing}from'@/hooks'
14+
//import { useViewing } from '@/hooks'
1515

1616
importFilterButtonfrom'./FilterButton'
1717
importSelectedFiltersfrom'./SelectedFilters'
@@ -46,13 +46,14 @@ const ArticlesFilter: FC<TProps> = ({
4646
totalCount=0,
4747
resState=TYPE.RES_STATE.DONE,
4848
})=>{
49-
const{ activeThread}=useViewing()
49+
// NOTE: 这里使用 useViewing 会导致 build-size blow
50+
// const { activeThread } = useViewing()
5051

5152
return(
5253
<Wrapper>
5354
<MainFilterWrapper>
5455
<FilterButton
55-
thread={activeThread}
56+
thread={THREAD.POST}
5657
onSelect={onSelect}
5758
activeFilter={activeFilter}
5859
/>

‎src/components/ArticlesFilter/FilterButton.tsx‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import dynamic from 'next/dynamic'
33

44
importtype{TThread,TArticleFilter}from'@/spec'
55
import{ICON_CMD}from'@/config'
6-
import{useAccount}from'@/hooks'
76

87
importTooltipfrom'@/components/Tooltip'
98

@@ -14,7 +13,7 @@ import {
1413
FilterIcon,
1514
}from'./styles/filter_button'
1615

17-
constFilterPanel=dynamic(()=>import('./FilterPanel/index'),{
16+
constFilterPanel=dynamic(()=>import('./FilterPanel'),{
1817
/* eslint-disable react/display-name */
1918
loading:()=><div/>,
2019
ssr:false,
@@ -27,8 +26,6 @@ type TProps = {
2726
}
2827

2928
constFilterButton:FC<TProps>=({ thread, onSelect, activeFilter})=>{
30-
const{ isLogin}=useAccount()
31-
3229
return(
3330
<Wrapper>
3431
<Tooltip
@@ -40,7 +37,6 @@ const FilterButton: FC<TProps> = ({ thread, onSelect, activeFilter }) => {
4037
<FilterPanel
4138
thread={thread}
4239
onSelect={onSelect}
43-
isLogin={isLogin}
4440
activeFilter={activeFilter}
4541
/>
4642
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp