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.

build(reduice-size): globally#1130

Merged
mydearxym merged 15 commits intodevfromuse-local-svg
Jul 30, 2021
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
15 commits
Select commitHold shift + click to select a range
652204d
chore: add local svg icons
mydearxymJul 29, 2021
5a716e2
chore: use local svgs
mydearxymJul 29, 2021
c1eef7c
build(size): reduce size by rm i18n && dynamic load
mydearxymJul 29, 2021
0b919be
build(size): reduce size by rm i18n && dynamic load
mydearxymJul 29, 2021
070f86b
build(size): reduce size by rm i18n && dynamic load
mydearxymJul 30, 2021
7bea682
chore: reduce build size wip
mydearxymJul 30, 2021
8436252
chore: reduce build size wip
mydearxymJul 30, 2021
dbdace5
build(size): reduce size wip
mydearxymJul 30, 2021
4020143
chore: remove un-used container
mydearxymJul 30, 2021
e1c8fa6
chore: test dynamic waypoint tracker
mydearxymJul 30, 2021
fa2535d
chore: move waypoint load to client
mydearxymJul 30, 2021
dc1488f
build(size): fix crash
mydearxymJul 30, 2021
e950c57
build(size): remove unused part
mydearxymJul 30, 2021
05a7538
build(size): drop sentry support
mydearxymJul 30, 2021
96aa1a0
chore: trigger ci
mydearxymJul 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions.eslintrc.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,6 +32,7 @@ module.exports = {
'@/schemas': 'src/schemas',
'@/Img': 'src/components/Img',
'@/SvgIcons': 'src/components/SvgIcons',
'@/icons': 'src/components/Icons',
'@/i18n': 'i18n',
'@/spec': 'src/spec',
},
Expand All@@ -40,6 +41,7 @@ module.exports = {
},
},
rules: {
'@typescript-eslint/no-var-requires': 0,
'@typescript-eslint/ban-ts-comment': 0,
'react/jsx-uses-react': 'off',
'react/react-in-jsx-scope': 'off',
Expand Down
1 change: 1 addition & 0 deletionsjsconfig.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,6 +16,7 @@
"@/schemas": ["src/schemas"],
"@/Img": ["src/components/Img"],
"@/SvgIcons/*": ["src/components/SvgIcons/*"],
"@/icons/*": ["src/components/icons/*"],
"@/i18n": ["i18n"]
}
},
Expand Down
3 changes: 0 additions & 3 deletionsnext.config.docker.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,9 +24,6 @@ const nextConfig = {
'process.env.SENTRY_RELEASE': JSON.stringify(buildId),
}),
)
if (!isServer) {
config.resolve.alias['@sentry/node'] = '@sentry/browser'
}

return config
},
Expand Down
50 changes: 9 additions & 41 deletionsnext.config.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,17 +10,17 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
const offlineConfig = require('./config/next_offline')

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

const {
NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
SENTRY_ORG,
SENTRY_PROJECT,
SENTRY_AUTH_TOKEN,
NODE_ENV,
} = process.env
//const {
// NEXT_PUBLIC_SENTRY_DSN: SENTRY_DSN,
// SENTRY_ORG,
// SENTRY_PROJECT,
// SENTRY_AUTH_TOKEN,
// NODE_ENV,
//} = process.env

process.env.SENTRY_DSN = SENTRY_DSN
//process.env.SENTRY_DSN = SENTRY_DSN

// next-plugins end

Expand All@@ -34,38 +34,6 @@ const nextConfig = {
new webpack.ContextReplacementPlugin(/moment[/\\]locale$/, /(en)/),
)

// for sentry
config.plugins.push(
new webpack.DefinePlugin({
'process.env.SENTRY_RELEASE': JSON.stringify(buildId),
}),
)
if (!isServer) {
config.resolve.alias['@sentry/node'] = '@sentry/browser'
}

// When all the Sentry configuration env variables are available/configured
// The Sentry webpack plugin gets pushed to the webpack plugins to build
// and upload the source maps to sentry.
// This is an alternative to manually uploading the source maps
// Note: This is disabled in development mode.
if (
SENTRY_DSN &&
SENTRY_ORG &&
SENTRY_PROJECT &&
SENTRY_AUTH_TOKEN &&
NODE_ENV === 'production'
) {
config.plugins.push(
new SentryWebpackPlugin({
include: '.next',
ignore: ['node_modules'],
urlPrefix: '~/_next',
release: buildId,
}),
)
}

return config
},
}
Expand Down
3 changes: 1 addition & 2 deletionspackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -84,7 +84,6 @@
"graphql-voyager": "^1.0.0-rc.31",
"js-cookie": "^2.2.0",
"mastani-codehighlight": "0.0.7",
"mobile-device-detect": "^0.4.3",
"mobx": "6.3.2",
"mobx-react": "7.2.0",
"mobx-react-lite": "3.2.0",
Expand All@@ -95,7 +94,6 @@
"next-compose-plugins": "^2.2.0",
"next-i18next": "4.4.1",
"next-offline": "4.0.6",
"next-seo": "4.4.0",
"nextjs-progressbar": "^0.0.6",
"overlayscrollbars": "1.13.1",
"path-match": "^1.2.4",
Expand All@@ -110,6 +108,7 @@
"react-calendar-heatmap": "1.8.1",
"react-content-loader": "3.4.2",
"react-copy-to-clipboard": "^5.0.3",
"react-device-detect": "^1.17.0",
"react-dom": "17.0.2",
"react-highlight-words": "^0.16.0",
"react-lazy-load-image-component": "1.5.0",
Expand Down
9 changes: 5 additions & 4 deletionsserver/index.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-var-requires */
/**
*
* this server is only used for next.js SSR
Expand All@@ -13,8 +14,8 @@ const mobxReact = require('mobx-react')
// inspect graphql model
const { express: voyagerMiddleware } = require('graphql-voyager/middleware')
// i18n setup
const nextI18NextMiddleware = require('next-i18next/middleware').default
const nextI18next = require('../i18n')
//const nextI18NextMiddleware = require('next-i18next/middleware').default
//const nextI18next = require('../i18n')

const app = require('./app')
const { redirectToNakedUrl } = require('./helper')
Expand DownExpand Up@@ -44,8 +45,8 @@ mobxReact.enableStaticRendering(true)
voyagerMiddleware({ endpointUrl: CONFIG.GRAPHQL_ENDPOINT }),
)

await nextI18next.initPromise
server.use(nextI18NextMiddleware(nextI18next))
//await nextI18next.initPromise
//server.use(nextI18NextMiddleware(nextI18next))

// eslint-disable-next-line global-require
server.use('/', require('./routes'))
Expand Down
5 changes: 2 additions & 3 deletionssrc/components/ArticleBaseStats/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,7 +7,6 @@
import { FC, memo } from 'react'

import type { TArticle, TContainer } from '@/spec'
import { ICON } from '@/config'
import { buildLog, scrollToComments } from '@/utils'

import { Space } from '@/components/Common'
Expand DownExpand Up@@ -36,11 +35,11 @@ const ArticleBaseStats: FC<TProps> = ({
}) => {
return (
<Wrapper testid={testid}>
<ViewsIconsrc={`${ICON}/article/viewed.svg`}/>
<ViewsIcon />
<Count>{article.views}</Count>
<Space left={14} />
<CommentWrapper onClick={() => scrollToComments(container)}>
<CommentIconsrc={`${ICON}/article/comment.svg`}/>
<CommentIcon />
<CommentCount>{article.commentsCount}</CommentCount>
</CommentWrapper>
</Wrapper>
Expand Down
14 changes: 9 additions & 5 deletionssrc/components/ArticleBaseStats/styles/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,25 +2,29 @@ import styled from 'styled-components'

import type { TTestable } from '@/spec'

import Img from '@/Img'
import ViewSVGIcon from '@/icons/View'
import CommentSVGIcon from '@/icons/Comment'

import { css, theme } from '@/utils'

export const Wrapper = styled.div.attrs(({ testid }: TTestable) => ({
'data-test-id': testid,
}))<TTestable>`
${css.flex('align-center')};
`
constIcon = styled(Img)`
exportconstViewsIcon = styled(ViewSVGIcon)`
fill: ${theme('thread.articleDigest')};
${css.size(14)};
transition: fill 0.25s;
`
export const ViewsIcon = styled(Icon)``

export const CommentWrapper = styled.div`
${css.flex('align-center')};
`
export const CommentIcon = styled(Icon)`
export const CommentIcon = styled(CommentSVGIcon)`
fill: ${theme('thread.articleDigest')};
${css.size(14)};
transition: fill 0.25s;

${CommentWrapper}:hover & {
cursor: pointer;
fill: ${theme('thread.articleTitle')};
Expand Down
9 changes: 5 additions & 4 deletionssrc/components/ArticlesFilter/DesktopView.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,9 +9,9 @@ import dynamic from 'next/dynamic'

import type { TArticleFilter, TResState } from '@/spec'

import { TYPE } from '@/constant'
import { TYPE, THREAD } from '@/constant'
import { buildLog } from '@/utils'
import { useViewing } from '@/hooks'
//import { useViewing } from '@/hooks'

import FilterButton from './FilterButton'
import SelectedFilters from './SelectedFilters'
Expand DownExpand Up@@ -46,13 +46,14 @@ const ArticlesFilter: FC<TProps> = ({
totalCount = 0,
resState = TYPE.RES_STATE.DONE,
}) => {
const { activeThread } = useViewing()
// NOTE: 这里使用 useViewing 会导致 build-size blow
// const { activeThread } = useViewing()

return (
<Wrapper>
<MainFilterWrapper>
<FilterButton
thread={activeThread}
thread={THREAD.POST}
onSelect={onSelect}
activeFilter={activeFilter}
/>
Expand Down
6 changes: 1 addition & 5 deletionssrc/components/ArticlesFilter/FilterButton.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@ import dynamic from 'next/dynamic'

import type { TThread, TArticleFilter } from '@/spec'
import { ICON_CMD } from '@/config'
import { useAccount } from '@/hooks'

import Tooltip from '@/components/Tooltip'

Expand All@@ -14,7 +13,7 @@ import {
FilterIcon,
} from './styles/filter_button'

const FilterPanel = dynamic(() => import('./FilterPanel/index'), {
const FilterPanel = dynamic(() => import('./FilterPanel'), {
/* eslint-disable react/display-name */
loading: () => <div />,
ssr: false,
Expand All@@ -27,8 +26,6 @@ type TProps = {
}

const FilterButton: FC<TProps> = ({ thread, onSelect, activeFilter }) => {
const { isLogin } = useAccount()

return (
<Wrapper>
<Tooltip
Expand All@@ -40,7 +37,6 @@ const FilterButton: FC<TProps> = ({ thread, onSelect, activeFilter }) => {
<FilterPanel
thread={thread}
onSelect={onSelect}
isLogin={isLogin}
activeFilter={activeFilter}
/>
)
Expand Down
11 changes: 4 additions & 7 deletionssrc/components/ArticlesFilter/FilterPanel/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,7 @@ import { FC, memo } from 'react'

import type { TThread, TArticleFilter } from '@/spec'
import { THREAD } from '@/constant'
import { useAccount } from '@/hooks'

import TimeFilter from './TimeFilter'
import SortFilter from './SortFilter'
Expand All@@ -15,15 +16,11 @@ type TProps = {
activeFilter: TArticleFilter
onSelect: (filter: TArticleFilter) => void
thread: TThread
isLogin?: boolean
}

const FilterPanel: FC<TProps> = ({
thread,
activeFilter,
onSelect,
isLogin,
}) => {
const FilterPanel: FC<TProps> = ({ thread, activeFilter, onSelect }) => {
const { isLogin } = useAccount()

switch (thread) {
case THREAD.POST:
return (
Expand Down
4 changes: 1 addition & 3 deletionssrc/components/ArticlesFilter/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,7 +6,7 @@

import { Fragment, memo } from 'react'

import {useDevice } from '@/hooks'
import {isMobile } from 'react-device-detect'
import { buildLog } from '@/utils'

import DesktopView from './DesktopView'
Expand All@@ -15,8 +15,6 @@ import DesktopView from './DesktopView'
const log = buildLog('c:ArticlesFilter:index')

const ArticlesFilter = (props) => {
const { isMobile } = useDevice()

return <Fragment>{!isMobile && <DesktopView {...props} />}</Fragment>
}

Expand Down
2 changes: 1 addition & 1 deletionsrc/components/ArticlesFilter/styles/filter_button.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components'

import{Button}from '@/components/Buttons'
import Button from '@/components/Buttons/Button'
import { theme, css } from '@/utils'
import Img from '@/Img'

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp