일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- CJ대한통운 #쿠팡 #통관번호오류 #통관고유번호오류 #안주원팀장 #모건인베스트
- NUGU
- 척추관협착증
- XSS
- shell_gpt
- 네이버카페
- Frida
- intelmac
- 변태는
- Sequoia
- ssrf
- 중고나라
- Malware Sample
- 보이스피싱 #대검찰청 #명의도용 #비밀번호 #계좌번호 #공공기관 #가짜검찰청
- ue4dumper
- 로맨스스캠
- 거래사기
- open redirect
- self-signed
- 많다..
- esbuild
- react
- 모의해킹
- CryptoJS
- 취약점
- speed-measure-webpack-plugin
- 채팅환전사기
- 허리디스크
- 안전결제
- MongoDB #NoSQL #CreateUser #DropUser #mongod #mognod.conf
Archives
- Today
- Total
annyoung
CRACO React esbuild with speed-measure-webpack-plugin 본문
https://github.com/stephencookdev/speed-measure-webpack-plugin
CRACO 환경에서 speed-measure-webpack-plugin를 사용하기 위해선 다음과 같이 설정하면 된다.
단, CRACO 환경에서 speed-measure-webpack-plugin를 적용시키면 버그가 있다. 현재 Github CI/CD Action을 통해서 빌드 후 자동으로 S3로 배포하고 있는데 webpack config이 오버라이딩 되면서 HtmlWebpackPlugin가 정상적으로 동작하지 않는다.
이로 인해서 %PUBLIC_URL%
이 치환되지 않기 때문에 클라이언트에서 favicon.ico
나 manifest.json
등이 로드가 안되는 이슈가 생겼다.
해결 해보려고 했으나 해결 불가.. 그래도 빌드 속도 측정은 꼭 해야겠다 싶으면 다음과 같이 적용시키면 된다. (배포할때는 빼는 것도 나쁘지 않은 방법인듯)
const CracoAlias = require("craco-alias");
const CracoEsbuildPlugin = require('craco-esbuild');
const SpeedMeasurePlugin = require("speed-measure-webpack-plugin");
const smp = new SpeedMeasurePlugin();
module.exports = {
webpack: {
// when i using the smp.wrap will be occur bug (PUBLIC_URL doesn't work).
configure: webpackConfig => smp.wrap(webpackConfig),
},
plugins: [
{
plugin: CracoAlias,
options: {
source: "jsconfig",
jsConfigPath: "jsconfig.paths.json",
},
},
{
plugin: CracoEsbuildPlugin,
options: {
esbuildLoaderOptions: {
// Optional. Defaults to auto-detect loader.
loader: 'tsx', // Set the value to 'tsx' if you use typescript
target: 'es2015',
},
esbuildMinimizerOptions: {
// Optional. Defaults to:
target: 'es2015',
css: true, // if true, OptimizeCssAssetsWebpackPlugin will also be replaced by esbuild.
},
esbuildJestOptions: {
sourcemap: false,
loaders: {
'.ts': 'ts',
'.js': 'tsx',
'.jsx': 'tsx',
'.tsx': 'tsx',
},
},
},
},
{
plugin: {
overrideCracoConfig: ({ cracoConfig, pluginOptions, context: { env, paths } }) => {
return cracoConfig;
},
overrideWebpackConfig: ({ webpackConfig, cracoConfig, pluginOptions, context: { env, paths } }) => {
return webpackConfig;
},
overrideDevServerConfig: ({ devServerConfig, cracoConfig, pluginOptions, context: { env, paths, proxy, allowedHost } }) => {
return devServerConfig;
},
overrideJestConfig: ({ jestConfig, cracoConfig, pluginOptions, context: { env, paths, resolve, rootDir } }) => {
return jestConfig
},
},
options: {},
},
],
};
craco.config.js: CRACO 기본 설정 파일
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"assets/*": ["./src/assets/*"]
}
}
}
jsconfig.json: 절대경로로 import할 수 있도록 설정
nopsled@playground ~/WebstormProjects/copies-client-v2 main npm run build
> copies-client-v2@0.1.0 build /Users/nopsled/WebstormProjects/copies-client-v2
> CI=false craco build
Creating an optimized production build...
^C
npm run build
> copies-client-v2@0.1.0 build /Users/nopsled/WebstormProjects/copies-client-v2
> CI=false craco build
Creating an optimized production build...
SMP ⏱
General output time took 52.29 secs
SMP ⏱ Plugins
IgnorePlugin took 6.6 secs
ESLintWebpackPlugin took 3.71 secs
CKEditorWebpackPlugin took 2.28 secs
HtmlWebpackPlugin took 0.201 secs
ManifestPlugin took 0.111 secs
CopyPlugin took 0.036 secs
MiniCssExtractPlugin took 0.022 secs
InlineChunkHtmlPlugin took 0.002 secs
InterpolateHtmlPlugin took 0.002 secs
ModuleNotFoundPlugin took 0.001 secs
DefinePlugin took 0 secs
SMP ⏱ Loaders
mini-css-extract-plugin, and
css-loader, and
postcss-loader, and
resolve-url-loader, and
sass-loader took 35.13 secs
module count = 2
css-loader, and
postcss-loader, and
resolve-url-loader, and
sass-loader took 35.003 secs
module count = 7
modules with no loaders took 32.57 secs
module count = 3170
postcss-loader took 23.99 secs
module count = 56
esbuild-loader took 15.5 secs
module count = 356
raw-loader took 3.24 secs
module count = 61
url-loader took 2.29 secs
module count = 34
mini-css-extract-plugin, and
css-loader, and
postcss-loader took 2.29 secs
module count = 5
css-loader, and
postcss-loader took 2.15 secs
module count = 5
file-loader took 1.64 secs
module count = 40
style-loader, and
postcss-loader took 0.125 secs
module count = 56
html-webpack-plugin took 0.022 secs
module count = 1
설정하고 빌드해보면 위와 같이 보인다.
아무튼 CRACO 환경에서 speed-measure-webpack-plugin을 적용하면 %PUBLIC_URL%
이 치환되지 않는 버그가 있다는 것만 알아주시면될 것 같다.
'프로그래밍' 카테고리의 다른 글
python 버전 관리를 위한 pyenv (0) | 2023.08.04 |
---|---|
https local domain with self-signed certificate (0) | 2022.04.15 |
flask with libreoffice (docx to pdf) (0) | 2022.02.25 |
아이폰 코로나 알림이 네이버 업데이트 (0) | 2022.01.23 |
react ckeditor5 build with craco without eject (0) | 2021.12.30 |
Comments