Skip to content
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

[FE] fix: Brotli 압축 플러그인 교체 #704

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"@typescript-eslint/parser": "^7.16.0",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"brotli-webpack-plugin": "^1.1.0",
"clean-webpack-plugin": "^4.0.0",
"compression-webpack-plugin": "^11.1.0",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand Down Expand Up @@ -75,7 +75,8 @@
"webpack": "^5.92.1",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.1.0"
"webpack-dev-server": "^5.1.0",
"zlib": "^1.0.5"
},
"msw": {
"workerDirectory": [
Expand Down
30 changes: 17 additions & 13 deletions frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const Dotenv = require('dotenv-webpack');
const { sentryWebpackPlugin } = require('@sentry/webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const TerserPlugin = require('terser-webpack-plugin');
const BrotliPlugin = require('brotli-webpack-plugin');
const CompressionPlugin = require('compression-webpack-plugin');
const zlib = require('zlib');

module.exports = (env, argv) => {
const isProduction = argv.mode === 'production';
Expand Down Expand Up @@ -59,27 +60,30 @@ module.exports = (env, argv) => {
systemvars: true,
path: './.env',
}),
//new BundleAnalyzerPlugin(),
...(isProduction
? [
new BrotliPlugin({
asset: '[path].br[query]', // .br 확장자 설정
new CompressionPlugin({
filename: '[path][base].br',
algorithm: 'brotliCompress', // Brotli 압축 사용
test: /\.(js|jsx|ts|tsx|css|html|svg|ico)$/, // 압축할 파일 유형
threshold: 8192, // 8KB 이상의 파일만 압축
minRatio: 0.8, // 압축 후 80% 이하로 줄어든 파일만 압축
quality: 11, // 최대 압축률 (0~11 사이, 기본값: 11)
compressionOptions: {
level: 11, // 압축 수준 (0~11, 기본값: 11)
},
deleteOriginalAssets: false, // 원본 파일을 삭제하지 않음
}),
sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'review-me',
project: 'woowacourse-review-me',
sourcemaps: {
filesToDeleteAfterUpload: '**/*.js.map',
},
}),
]
: []),
//new BundleAnalyzerPlugin(),
sentryWebpackPlugin({
authToken: process.env.SENTRY_AUTH_TOKEN,
org: 'review-me',
project: 'woowacourse-review-me',
sourcemaps: {
filesToDeleteAfterUpload: '**/*.js.map',
},
}),
],
devtool: isProduction ? 'hidden-source-map' : 'eval',
devServer: {
Expand Down
Loading