egjs-flicking icon indicating copy to clipboard operation
egjs-flicking copied to clipboard

fix: add css files to sideEffects field of all packages

Open taejs opened this issue 3 years ago โ€ข 4 comments

Issue

fixes https://github.com/naver/egjs-flicking/issues/708, https://github.com/naver/egjs-flicking/issues/573

Details

์ด์Šˆ ์žฌํ˜„

์ด์Šˆ๋Š” nuxt + production ํ™˜๊ฒฝ์ผ ๋•Œ flicking.cssํŒŒ์ผ์ด ์‚ฌ๋ผ์ง„๋‹ค๋Š” ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. ์ œ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์ด react + ์ž์ฒด ssr + production ํ™˜๊ฒฝ์ž„์—๋„ ํ•ด๋‹น ํ˜„์ƒ์ด ์žฌํ˜„๋˜์–ด ๊ณตํ†ต์ ์„ ์ฐพ์•„๋ณด์•˜์Šต๋‹ˆ๋‹ค.

webpack@4 production ํ™˜๊ฒฝ์—์„œ๋งŒ MiniCssExtractPlugin(webpack@4 ํ˜ธํ™˜ 1.6.2), OptimizeCSSAssetsPlugin์ด ์ ์šฉ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ์žฌํ˜„์ด ๊ฐ€๋Šฅํ•œ๊ฒƒ์œผ๋กœ ๋ณด์ž…๋‹ˆ๋‹ค. develop ํ™˜๊ฒฝ์—์„œ๋Š” style-loader๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

eg-js/flicking์€ v4๋กœ ๋ฒ„์ „์—… ๋˜๋ฉด์„œ dist์˜ css ํŒŒ์ผ์„ importํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ณ€๊ฒฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ package.json์˜ sideEffects๊ฐ€ cssํŒŒ์ผ์„ ๋ณ„๋„๋กœ ์ œ๊ณตํ•˜์ง€ ์•Š์„๋•Œ ๊ธฐ์ค€ ๊ทธ๋Œ€๋กœ false๋กœ ์ ์šฉ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค. ์ด ๋ถ€๋ถ„์„ ๋ณ€๊ฒฝํ•ด์ฃผ๋ฉด Flicking.css๊ฐ€ MiniCssExtractPlugin 1.6.2์—์„œ๋„ ์‚ฌ๋ผ์ง€์ง€ ์•Š๋Š”๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ž„์‹œ ํ•ด๊ฒฐ๋ฐฉ๋ฒ•์œผ๋กœ๋Š” ์•„๋ž˜ ๋‚ด์šฉ์„ ์ด์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Webpack - Mark the file as side-effect-free

๋งˆ์ง€๋ง‰์œผ๋กœ "sideEffects"๋Š” [module.rules ์˜ต์…˜](https://webpack.kr/configuration/module/#modulerules)์œผ๋กœ๋„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์šฐ์„  ์ €๋Š” ์ œ ๊ฐœ๋ฐœํ™˜๊ฒฝ์— ์•„๋ž˜ ์ž„์‹œ ๋ฐฉํŽธ์„ ์ ์šฉํ•ด๋‘˜ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค.

์ด pr์€ ์ •ํ™•ํ•œ ์›์ธ์„ ์ฐพ์ง€ ๋ชปํ•˜๊ณ  ํ‘œ๋ฉด์ ์ธ ํ˜„์ƒ๋งŒ ์ˆ˜์ •ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— closed ๋˜์–ด๋„ ๋ฌด๊ด€ํ•ฉ๋‹ˆ๋‹ค.

taejs avatar Aug 01 '22 07:08 taejs

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Aug 01 '22 07:08 CLAassistant

@taejs Thanks for fixing the issue! As we additionally provide sass files, I think merging this PR is fine after adding .sass at package.json file.

WoodNeck avatar Aug 03 '22 02:08 WoodNeck

I added sass in sideEffects field. And removed the specific directory name(dist) because it's unnecessary.

"dist/.css" - > ".css", "*.sass"

taejs avatar Aug 04 '22 00:08 taejs

The array accepts simple glob patterns to the relevant files. It uses glob-to-regexp under the hood (Supports: *, **, {a,b}, [a-z]). Patterns like .css, which do not include a /, will be treated like **/.css.

Following webpack guide, .css treated like **/.css in sideEffects field.

On second thought, It could be better to add a directory wild card since other bundlers don't guarantee this. Thanks for the review!

taejs avatar Aug 04 '22 01:08 taejs

Is there any update on this?

BrandonKuenzi avatar Aug 25 '22 22:08 BrandonKuenzi