egjs-flicking
egjs-flicking copied to clipboard
fix: add css files to sideEffects field of all packages
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 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.
I added sass in sideEffects field.
And removed the specific directory name(dist) because it's unnecessary.
"dist/.css" - > ".css", "*.sass"
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!
Is there any update on this?