-
Notifications
You must be signed in to change notification settings - Fork 6
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: 이미지 최적화 #485
The head ref may contain hidden characters: "478-feat-\uC774\uBBF8\uC9C0-\uCD5C\uC801\uD654"
feat: 이미지 최적화 #485
Changes from 13 commits
ba88445
ba4eab3
fd01a5f
0454dc9
140a3cf
3f2ab9c
cb20b01
d28a113
2c74eb0
feeb345
d385153
f041e01
59d609c
31cf52e
538e860
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,7 @@ | |
{ | ||
"runtime": "automatic" | ||
} | ||
], | ||
"@babel/preset-typescript" | ||
] | ||
], | ||
"plugins": [ | ||
[ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,12 @@ | ||
const path = require('path'); | ||
|
||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
|
||
const Dotenv = require('dotenv-webpack'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
mode: process.env.NODE_ENV, | ||
entry: ['./src/index.tsx'], | ||
output: { | ||
path: path.resolve(__dirname, '../dist/'), | ||
publicPath: '/', | ||
filename: '[name].[chunkhash:8].js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. chunkhash:8이면 8자리로 나오는 건가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 하면 해쉬값으로 식별을 하여 캐시 버스팅할 수 있겠네요 |
||
clean: true, | ||
}, | ||
resolve: { | ||
|
@@ -61,15 +57,4 @@ module.exports = { | |
historyApiFallback: true, | ||
allowedHosts: 'all', | ||
}, | ||
|
||
plugins: [ | ||
new HtmlWebpackPlugin({ | ||
template: './public/index.html', | ||
filename: 'index.html', | ||
}), | ||
new ForkTsCheckerWebpackPlugin(), | ||
new Dotenv({ | ||
path: path.resolve(__dirname, `../.dev.env`), | ||
}), | ||
], | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,28 @@ | ||
const productionConfig = require('./webpack.prod.js'); | ||
const developmentConfig = require('./webpack.dev.js'); | ||
const localConfig = require('./webpack.local.js'); | ||
const path = require('path'); | ||
const commonConfig = require('./webpack.common.js'); | ||
|
||
const HtmlWebpackPlugin = require('html-webpack-plugin'); | ||
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
const Dotenv = require('dotenv-webpack'); | ||
|
||
const commonPlugins = [ | ||
new HtmlWebpackPlugin({ | ||
template: './public/index.html', | ||
filename: 'index.html', | ||
}), | ||
new ForkTsCheckerWebpackPlugin(), | ||
]; | ||
|
||
module.exports = (env, args) => { | ||
const { TARGET_ENV } = env; | ||
|
||
switch (TARGET_ENV) { | ||
case 'msw': | ||
return localConfig; | ||
case 'dev': | ||
return developmentConfig; | ||
case 'prod': | ||
return productionConfig; | ||
default: | ||
throw new Error('No matching configuration was found!'); | ||
} | ||
return { | ||
...commonConfig, | ||
plugins: [ | ||
...commonPlugins, | ||
new Dotenv({ | ||
path: path.resolve(__dirname, `../.${TARGET_ENV}.env`), | ||
}), | ||
], | ||
}; | ||
}; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,11 @@ | |
"main": "index.tsx", | ||
"license": "MIT", | ||
"scripts": { | ||
"start:msw": "webpack serve --port 3000 --env TARGET_ENV=msw", | ||
"start:dev": "webpack serve --port 3000 --env TARGET_ENV=dev", | ||
"start:prod": "webpack serve --port 3000 --env TARGET_ENV=prod", | ||
"build:dev": "webpack --env TARGET_ENV=dev", | ||
"build:prod": "webpack --env TARGET_ENV=prod", | ||
"start:msw": "webpack serve --port 3000 --env TARGET_ENV=msw --mode development", | ||
"start:dev": "webpack serve --port 3000 --env TARGET_ENV=dev --mode production", | ||
"start:prod": "webpack serve --port 3000 --env TARGET_ENV=prod --mode production", | ||
Comment on lines
+7
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시 msw에 전용 환경 구성은 못할까요?? |
||
"build:dev": "webpack --env TARGET_ENV=dev --mode production", | ||
"build:prod": "webpack --env TARGET_ENV=prod --mode production", | ||
"lint": "eslint \"src/**/*.{js,jsx,ts,tsx}\"", | ||
"lint:css": "stylelint './src/**/*.{tsx,ts,jsx,js}'", | ||
"lint:css:fix": "stylelint './src/**/*.{tsx,ts,jsx,js}' --fix", | ||
|
@@ -21,36 +21,36 @@ | |
}, | ||
"dependencies": { | ||
"@googlemaps/react-wrapper": "^1.1.35", | ||
"@storybook/react": "^7.0.25", | ||
"@storybook/react-webpack5": "^7.0.25", | ||
"@tanstack/react-query": "^4.32.0", | ||
"@tanstack/react-query-devtools": "^4.32.0", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@types/react": "^18.2.14", | ||
"@types/react-dom": "^18.2.6", | ||
"@types/styled-components": "^5.1.26", | ||
"axios": "^1.4.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.14.2", | ||
"styled-components": "^6.0.2", | ||
"zustand": "^4.3.9", | ||
"typescript": "^5.1.6" | ||
}, | ||
"devDependencies": { | ||
"@types/styled-components": "^5.1.26", | ||
"ts-loader": "^9.4.4", | ||
"babel-plugin-root-import": "^6.6.0", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"cypress": "^12.17.3", | ||
"dotenv": "^16.3.1", | ||
"fork-ts-checker-webpack-plugin": "^8.0.0", | ||
"html-webpack-plugin": "^5.5.3", | ||
"msw": "^1.2.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-router-dom": "^6.14.2", | ||
"copy-webpack-plugin": "^11.0.0", | ||
"@tanstack/react-query-devtools": "^4.32.0", | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@types/react": "^18.2.14", | ||
"@types/react-dom": "^18.2.6", | ||
"@storybook/react": "^7.0.25", | ||
"@storybook/react-webpack5": "^7.0.25", | ||
"storybook": "^7.0.25", | ||
"styled-components": "^6.0.2", | ||
"ts-loader": "^9.4.4", | ||
"typescript": "^5.1.6", | ||
"webpack": "^5.88.1", | ||
"webpack-cli": "^5.1.4", | ||
"webpack-dev-server": "^4.15.1", | ||
"webpack-merge": "^5.9.0", | ||
"zustand": "^4.3.9" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.22.5", | ||
"@babel/preset-env": "^7.22.5", | ||
"@babel/preset-react": "^7.22.5", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import { Modal } from '~/components/@common/Modal'; | |
import useToastState from '~/hooks/store/useToastState'; | ||
import useMediaQuery from '~/hooks/useMediaQuery'; | ||
import { BORDER_RADIUS, FONT_SIZE } from '~/styles/common'; | ||
import getImgUrl from '~/utils/image'; | ||
|
||
interface StyledToastProps { | ||
isSuccess?: boolean; | ||
|
@@ -20,7 +21,12 @@ function Toast() { | |
<Modal open={open} close={close} isOpen={isOpen}> | ||
{isOpen && ( | ||
<StyledToastWrapper isSuccess={isSuccess} isMobile={isMobile}> | ||
{image && <StyledToastImg src={`https://www.celuveat.com/images-data/${image.url}`} alt={image.alt} />} | ||
{image && ( | ||
<picture> | ||
<StyledToastSource type="image/webp" srcSet={`${getImgUrl(image.url, 'webp')}`} /> | ||
<StyledToastImg src={`${getImgUrl(image.url, 'jpeg')}`} alt={image.alt} /> | ||
Comment on lines
+26
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수화되었으면 string으로 안 묶어줘도 될 것 같아요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. webp 미지원 브라우저에 대한 대응도 잘 해주셨네요! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
</picture> | ||
)} | ||
<StyledToastText>{text}</StyledToastText> | ||
</StyledToastWrapper> | ||
)} | ||
|
@@ -30,13 +36,21 @@ function Toast() { | |
|
||
export default Toast; | ||
|
||
const StyledToastImg = styled.img` | ||
const styledToastImgVariable = css` | ||
width: 44px; | ||
height: 44px; | ||
|
||
border-radius: ${BORDER_RADIUS.sm}; | ||
`; | ||
|
||
const StyledToastImg = styled.img` | ||
${styledToastImgVariable} | ||
`; | ||
|
||
const StyledToastSource = styled.source` | ||
${styledToastImgVariable} | ||
`; | ||
|
||
Comment on lines
-33
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아마 같은 css를 두 군데에서 다 쓰려고 묶은 것 같네요! 저는 공용css 만 묶어주었던지라.. 이런 상황에서 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
picture 태그 사용에 미숙해서 생긴 코드 같습니다! 숙지 후 수정했습니다!! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
공통된 css 가 불필요해서 삭제했습니다!!
|
||
const StyledToastText = styled.span` | ||
color: var(--gary-4); | ||
`; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏