3.2.1
์ด๋
https://codesandbox.io/s/jnw46698m3
1- antd ๊ตฌ์ฑ ์์ ๊ฐ์ ธ์ค๊ธฐ
2- ์ ์ญ ์คํ์ผ ๊ด์ฐฐ(h1,h6, selector, ect...)
๋ฒ์๊ฐ ์ง์ ๋๊ณ ๋๋จธ์ง ์์ฉ ํ๋ก๊ทธ๋จ์ ์ํฅ์ ์ฃผ์ง ์๋ ๊ตฌ์ฑ ์์ ์คํ์ผ์ ๋๋ค.
๊ตฌ์ฑ ์์๋ฅผ ๊ฐ์ ธ์ค๋ฉด ์ ์ฒด HTML ์์ฉ ํ๋ก๊ทธ๋จ(React ์ธ๋ถ์๋ ํฌํจ)์ ์คํ์ผ์ด ์ง์ ๋ฉ๋๋ค.
#9362 & #4331 ๋ฌธ์ ์ ๋ํ ๋ต๋ณ์ ๋๋ค.
https://github.com/react-component ์์ ์ง์ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํด ๋ณผ ์๋ ์์ต๋๋ค
antd
๊ทธ ์์ ๊ตฌ์ถ ํ๊ณ , ๊ทธ๋ค์ ์คํ์ผ์ด ์ ์ฉ๋์ง ์์ ์์ต๋๋ค.
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ญ์์ค. ์ฐ๋ฆฌ ์ฑ์ ํ๋ ๋ธ๋ก์ปค์ ๋๋ค.
์๋ ํ์ธ์, ์ฌ๋ฌ๋ถ์ ๊ฐ์ ์ด๋ ์คํ์ผ ๊ตฌ์ฑ ์์์ ๊ฐ์ CSS-in-JS ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋ํ ์๊ฐ์ ํด๋ณธ ์ ์ด ์์ต๋๊น? ์คํ์ผ์ ๋ํ ์ ์ญ ๊ฐ์ ธ์ค๊ธฐ ๋ฐ ant ๊ตฌ์ฑ ์์์ ๋ํ ์คํ์ผ ๋ฒ์ ์ง์ ๊ณผ ๊ฐ์ ๋ง์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ํ ํ ๋ง(๋์ ์คํ์ผ)๋ฅผ ๊ฐ์ ํ ์๋ ์์ต๋๋ค. ์ด๊ฒ์ด ๋ค๋ฅธ ๊ณณ์์ ๋ ผ์๋์๋ค๋ฉด ์ฌ๊ณผ๋๋ฆฝ๋๋ค. ๊ด๋ จ ํ ๋ก ์ ์ฐพ์ ์ ์์ต๋๋ค.
@divyanshu013 antd๋ ๊ตฌ์ฑ ์์/์๋ฐ์คํฌ๋ฆฝํธ๋ฟ๋ง ์๋๋ผ antd ์คํ์ผ ์ฌ์์ ํฌํจํ๊ธฐ ์ํ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ด ์ต์ฐ์ ์์๊ฐ ์๋๋ผ๋ ๊ฒ์ ์ฝ์ ๊ฒ ๊ฐ์ต๋๋ค. ๋ํ ์ด๊ฒ์ ๊ธฐ์ ์ ์ผ๋ก ๋ด๋ถ ํ๋ก์ ํธ์ ๋ํ ๋จ์ผ ์ ์ฅ์๋ฅผ ์๋ฏธํ๋ฏ๋ก ๋ค๋ฅธ ์ฌ๋์ ๋ธ๋๋์ ๋ํ ํ ๋ง ์ง์ ์ ์๋์ผ๋ก ์ต์ฐ์ ์์๊ฐ ์๋๋๋ค. ์ฆ, ๋๋ ๋น์ ๊ณผ ํจ๊ปํฉ๋๋ค. ์ ์ญ ์คํ์ผ๋ณด๋ค styled-components๋ฅผ ์ฌ์ฉํ์ผ๋ฉด ํฉ๋๋ค.
https://github.com/ant-design/ant-design/issues/5570#issuecomment -306960517
https://spectrum.chat/thread/ca82a625-134f-49df-9900-1b0b6342e037
์ข์, ๋๋ antd์ ๋ ํ์ผ ๊ตฌ์กฐ๋ฅผ ๊ทธ๋ ๊ฒ ๊น๊ฒ ๋ณด์ง ์์๋ค๋ ๊ฒ์ ์ธ์ ํด์ผ ํ๋ค. ๊ทธ๋์ ๋๊ตฐ๊ฐ๊ฐ ์ด๊ฒ์ ๋ํด ๋ฐํ ์ ์์ ๊ฒ์ด๋ค.
๋จ์ํ ๊ตฌ์ฑ ์์์ less ํ์ผ๋ง ํฌํจํ๋ ๊ฒ์ด ์ผ๋ง๋ ํฐ ๋ฒ์ฃ์ ๋๊น? ์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ ์์ ์ ์ํํฉ๋๋ค.
import { 'antd'์์ };
๊ฐ์ ธ์ค๊ธฐ 'antd/lib/select/style/index.less';
๊ฐ๋จํ ํ
์คํธ๋ฅผ ํด๋ณด๋ ์ ๋๋
์ด๊ฒ์ด ์
๋ฐ์ดํธ๋ก ์ธํด ์ค๋จ๋ ๊ฒ์ด๋ผ๊ณ ํ์ ํ์ง๋ง ๋ค๋ฅธ ์๋ฃจ์
๋ ์ํ์ ๊ฐ์ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
์ด๋ ๊ฐ๋ณ ๊ตฌ์ฑ ์์์ ๋ํ ์คํ์ผ์ ๊ฐ์ ธ์ฌ ์ ์๋ ๊ฒ๊ณผ ๊ด๋ จ์ด ์์ต๋๋ค. ๊ตฌ์ฑ ์์์ ์คํ์ผ์ด ์์ฒด ํฌํจ๋ ๊ฒฝ์ฐ ์ฌ๋๋ค์ ์ ์ญ ์ฌ์ค์ /์คํ์ผ์ ์ ํํ๊ฑฐ๋ ์ ํ ํด์ ํ ์ ์์ต๋๋ค.
์ง๊ธ ์ํฉ:
์ด๋ป๊ฒ ํ๋ฉด ๊ตฌ์ฑ ์์๋ฅผ ๊นจ์ง์ง ์๋ ๋ฐฉ์์ผ๋ก ์์ฒด์ ์ผ๋ก ํฌํจํ ์ ์์ต๋๊น? ํ ๊ฐ์ง ํด๊ฒฐ์ฑ ์ Storybook ์ ์ฌ์ฉํ์ฌ ์ผ๋ถ ๊ฒฉ๋ฆฌ๋ ์๊ฐ์ ํ๊ท ํ ์คํธ๋ฅผ ์ค์ ํ๋ ๊ฒ์ ๋๋ค.
์ ์ญ ์คํ์ผ์ด ํฌํจ๋ ์ค๋ ์ท์ ์์ฑํ ๋ค์ ์ ์ญ ์คํ์ผ์ ์ ๊ฑฐํ๊ณ ํ ์คํธ๋ฅผ ํต๊ณผํ ๋๊น์ง ๊ตฌ์ฑ ์์์ ์คํ์ผ์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
์ฐธ์กฐ #4331 #13459
_ ๋ฐ์ค๋ณต ๋ฌธ์ ๋ฅผ ๋ง๋ค์ด ์ฃ์กํฉ๋๋ค. ๋ํ๋ฅผ ํตํฉํ๊ธฐ ์ํด ์ฌ๊ธฐ์์ ์ฝ๊ฐ ๋ค๋ฅธ ์ง๋ฌธ์ ๋ค์ ํ ๊ฒ์._
์ปค๋ฎค๋ํฐ๊ฐ ๋ ์ด์ ์ ์ญ ์คํ์ผ์ ์์กดํ์ง ์๋๋ก ๊ตฌ์ฑ ์์ ์คํ์ผ์ ์ ํํ๋ ์์ ์ ์ํํ ์ ์๋ค๋ฉด ์ด๋จ๊น์?
ํ ๊ฐ์ง ์ ๊ทผ ๋ฐฉ์(@DylanVann ๊ฐ์ฌ):
[class="ant-"] { ... }
์ ๊ทผ ๋ฐฉ์ ์ ์ข์ํ์ง๋ง ์ฌ๊ธฐ์๋ ๋ง์ ์ต์
์ด ์์ต๋๋ค.Ant๋ ๋ค์์ ์ด๋ ค ์์ต๋๊น?
๋ชจ๋ ์ ๋ฐ์ดํธ?
์๋
ํ์ธ์!
๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ๊ตฌ์ฑ ์์ ์คํ์ผ์ ๊ฐ์ ธ์์ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
์ฒ์์๋ ๋ค์๊ณผ ๊ฐ์ ์คํ์ผ์ ๊ฐ์ ธ์์ต๋๋ค.
import 'antd/lib/button/style/css';
๊ทธ๋ฌ๋ css.js
๋ ๊ฐ์ ธ์ค๊ธฐ ๋ฒํผ์ ์คํ์ผ๋ฟ๋ง ์๋๋ผ ์ผ๋ฐ ์คํ์ผ๋ ๊ฐ์ ธ์ค๋ ๋ด์ฉ์
๋๋ค.
"use strict";
// General styling (body, h1, h2..)
require("../../style/index.css");
// Button styles
require("./index.css");
๊ทธ๋์ ๋ค์๊ณผ ๊ฐ์ด index.css
ํ์ผ์ ๊ฐ์ ธ์์ ํด๊ฒฐํ์ต๋๋ค.
import 'antd/lib/button/style/index.css';
์ข์ ๋ฐ๊ฒฌ!
๋ ์ด์์ index.css
ํ์ผ์ ์์กดํ๋ ๋ ๋ณต์กํ ๊ตฌ์ฑ ์์๊ฐ ์์ต๋๊น?
๊ธฐ๋ณธ ์ผ๋ฐ ์คํ์ผ ํ์ผ์ด ์์ผ๋ฉด ์ค๋จ๋๋ ๊ตฌ์ฑ ์์๊ฐ ์์ต๋๊น?
์ข์ ๋ฐ๊ฒฌ!
๊ฐ์ฌํฉ๋๋ค ๐
๋ ์ด์์
index.css
ํ์ผ์ ์์กดํ๋ ๋ ๋ณต์กํ ๊ตฌ์ฑ ์์๊ฐ ์์ต๋๊น?
์๋ง๋ ๊ทธ ๊ฒฝ์ฐ ๋ชจ๋ ํ์ผ์ ๊ฐ์ ธ์ฌ ๊ฒ์ ๋๋ค. ๋๋ฌด ๋ง์ง๋ ์์ ๊ฒ์ด๋ผ๊ณ ์๊ฐํฉ๋๋ค.
๊ธฐ๋ณธ ์ผ๋ฐ ์คํ์ผ ํ์ผ์ด ์์ผ๋ฉด ์ค๋จ๋๋ ๊ตฌ์ฑ ์์๊ฐ ์์ต๋๊น?
๋ฒํผ์ผ๋ก ์ ์๋ํ์ต๋๋ค(๋ด๊ฐ ์ฌ์ฉํ ์ ์ผํ ๊ตฌ์ฑ ์์).
๊ทธ๋ฌ๋ ์ผ๋ถ ๊ตฌ์ฑ ์์๋ ์ด๋ฌํ ์คํ์ผ์ ์ฌ์ฉํ ์ ์์ผ๋ฏ๋ก ํ์ธํด์ผ ํฉ๋๋ค.
@fedebabrauskas ์ ๊ฐ์ ๋ฐฉ์์ผ๋ก ํ๊ณ ๋ชจ๋ ๊ฒ์ด ์ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
@fedebabrauskas ๊ตฌ์ฑ ์์์ ๋ํ ์ ๋๋ฉ์ด์ ์ด ํ์ฑํ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค(ํ์ค๋ฒ๋ฅผ ์๋ํ์ง๋ง ์คํ์ผ์ ๊ด์ฐฎ์ง๋ง ์ ๋๋ฉ์ด์ ์ด ์์ต๋๋ค)
์ข์, ๋๋ antd์ ๋ ํ์ผ ๊ตฌ์กฐ๋ฅผ ๊ทธ๋ ๊ฒ ๊น๊ฒ ๋ณด์ง ์์๋ค๋ ๊ฒ์ ์ธ์ ํด์ผ ํ๋ค. ๊ทธ๋์ ๋๊ตฐ๊ฐ๊ฐ ์ด๊ฒ์ ๋ํด ๋ฐํ ์ ์์ ๊ฒ์ด๋ค.
๋จ์ํ ๊ตฌ์ฑ ์์์ less ํ์ผ๋ง ํฌํจํ๋ ๊ฒ์ด ์ผ๋ง๋ ํฐ ๋ฒ์ฃ์ ๋๊น? ์๋ฅผ ๋ค์ด ๋ค์๊ณผ ๊ฐ์ ์์ ์ ์ํํฉ๋๋ค.
import { 'antd'์์ };
๊ฐ์ ธ์ค๊ธฐ 'antd/lib/select/style/index.less';๋น ๋ฅธ ํ ์คํธ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ํ๋ฉด ์๋ํ๋ _๊ฒ์ฒ๋ผ_ ํด์ ํธ๊ธฐ์ฌ์ด ์๊ฒผ์ต๋๋ค...
์ด๊ฒ์ด ์ ๋ฐ์ดํธ๋ก ์ธํด ์ค๋จ๋ ๊ฒ์ด๋ผ๊ณ ํ์ ํ์ง๋ง ๋ค๋ฅธ ์๋ฃจ์ ๋ ์ํ์ ๊ฐ์ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
์ด๊ฒ์ ์๋ช
์ ์์ธ์
๋๋ค!
๋๋ import 'antd/dist/antd.css'๋ฅผ ์ฌ์ฉํ๊ณ ์์์ต๋๋ค
Google์์ ๊ฒ์ํ์ฌ ์ด ๋ฌธ์ ๋ฅผ ์ฐพ์์ต๋๋ค.
์ค์์น ๊ตฌ์ฑ ์์์ ๋ํ ์คํ์ผ๋ง ํ์ํ๊ธฐ ๋๋ฌธ์ import 'antd/lib/switch/style/index.less'๋ฅผ ์๋ํ์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ถ! ํจ๊ณผ๊ฐ ์์๋ค!!
๊ณ ๋ง์ ์น๊ตฌ์ผ!!
์ฝ๋ ๊ตฌํ
๋ฐฐํฌ๋ ํฌํธํด๋ฆฌ์ค
๊ทธ๋์ ํ์ธ์ ์ํด ์ค๋ ํ์ฌ index.css
์์
ํ ์ ์์ต๋๊น?
๋๋ Gatbsy๋ฅผ ์ฌ์ฉํ๊ณ ์๊ณ ๋ด global.css
๋ ๊ฐ๋ฏธ index.css
์ํด ๋ฎ์ด์ฐ์ฌ์ง๊ณ ์์ต๋๋ค.
ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก - ๋ฐฉ๊ธ ์๋์ ๊ฐ์ ์ฌํ ์ค์น ์คํฌ๋ฆฝํธ๋ฅผ ๋ง๋ค์์ต๋๋ค.
scripts/postinstall.js
#!/usr/bin/env node
const replace = require('replace-in-file');
const removeAntdGlobalStyles = () => {
const options = {
files: [`${process.cwd()}/node_modules/antd/lib/style/core/index.less`, `${process.cwd()}/node_modules/antd/es/style/core/index.less`],
from: "<strong i="8">@import</strong> 'base';",
to: '',
};
replace(options)
.then(() => {
console.log('[INFO] Successfully Removed Antd Global Styles:');
})
.catch(e => {
console.error('[ERR] Error removing Antd Global Styles:', e);
process.exit(1);
});
};
removeAntdGlobalStyles();
package.json
"devDependencies": {
//other dependancies
"replace-in-file": "^5.0.2"
},
"scripts": {
// other scripts
"postinstall": "node scripts/postintall.js"
}
์ฐธ๊ณ : ์ฃผ๋ฌธํ ๊ตฌ์ฑ ์์ ๊ฐ์ ธ ์ค๊ธฐ ์
ํด๊ฒฐ ๋ฐฉ๋ฒ์ผ๋ก - ๋ฐฉ๊ธ ์๋์ ๊ฐ์ ์ฌํ ์ค์น ์คํฌ๋ฆฝํธ๋ฅผ ๋ง๋ค์์ต๋๋ค.
scripts/postinstall.js
#!/usr/bin/env node const replace = require('replace-in-file'); const removeAntdGlobalStyles = () => { const options = { files: [`${process.cwd()}/node_modules/antd/lib/style/core/index.less`, `${process.cwd()}/node_modules/antd/es/style/core/index.less`], from: "<strong i="9">@import</strong> 'base';", to: '', }; replace(options) .then(() => { console.log('[INFO] Successfully Removed Antd Global Styles:'); }) .catch(e => { console.error('[ERR] Error removing Antd Global Styles:', e); process.exit(1); }); }; removeAntdGlobalStyles();
package.json
"devDependencies": { //other dependancies "replace-in-file": "^5.0.2" }, "scripts": { // other scripts "postinstall": "node scripts/postintall.js" }
์คํฌ๋ฆฝํธ๋ ๊ธฐ๋ณธ ์คํ์ผ์ ์ ๊ฑฐํ์ง๋ง ์ฌ์ ํ ์ ์ญ antd ์คํ์ผ์ ์ ๊ฑฐํ์ง ์์ต๋๋ค. ๊ฐ antd ๊ตฌ์ฑ ์์ ๋๋ ๋จ์ผ dist CSS ํ์ผ์ ๋ํ ์คํ์ผ์ ๊ฐ์ ธ์ค๋์?
@himanshuc3 ์ฃผ๋ฌธํ ๊ตฌ์ฑ ์์ ๊ฐ์ ธ ์ค๊ธฐ๋ฅผ ์ํด
@fedebabrauskas ๊ตฌ์ฑ ์์์ ๋ํ ์ ๋๋ฉ์ด์ ์ด ํ์ฑํ๋์ง ์์ ๊ฒ ๊ฐ์ต๋๋ค(ํ์ค๋ฒ๋ฅผ ์๋ํ์ง๋ง ์คํ์ผ์ ๊ด์ฐฎ์ง๋ง ์ ๋๋ฉ์ด์ ์ด ์์ต๋๋ค)
๊ฐ์ ๊ฒฝ์ฐ์ด์ง๋ง ์ถ์
babel-plugin-import
์ ์ญ ์คํ์ผ์ ๊ฐ์ ธ์ค๊ณ ,
๋ค์๊ณผ ๊ฐ์ด ํน์ ๊ตฌ์ฑ ์์ CSS ํ์ผ์ ๊ฐ์ ธ์ต๋๋ค.
import 'antd/lib/date-picker/style/index.css';
Datepicker๋ฅผ ๋์ต๋๋ค(์ด์ํ๊ณ ์์์น ๋ชปํ ๋ฐฉ์์ผ๋ก ์ด๋ฆฌ๊ณ ๋ซํ๋๋ค.)
๊ทธ๊ฒ์ ๋ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ต๋๊น?
์ธ์์ ๋ค๋ฅธ ๋ง์ ๊ตฌ์ฑ ์์์ ์์กดํ๋ ์ ์ก ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค ... ์ด์ ๋ชจ๋ ์ด๋์ด ํ์ดํฌ๊ทธ๋ํผ ํค๋๊ฐ ๊ธฐ๋ณธ ์์ ๋ฑ์ ๋ฐ๋ฅด์ง ์๋๋ค๋ ๊ฒ์ ๊นจ๋ซ์ต๋๋ค.
+1
+1
์ด๊ฒ์ ๋ค๋ฅธ ๊ตฌ์ฑ ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ํจ๊ป Ant Design์ ์ฌ์ฉํ๋ ๋ฐ๋ชจ ์ฑ์์ ์ฌ์ฉํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ๋๋ค.
index.scss
:
.antPage {
<strong i="8">@import</strong> '~antd/dist/antd.min';
...
}
์ด์ Ant์ ๋ชจ๋ ์ ์ญ ์คํ์ผ์ ๋ค์์คํ์ด์ค๊ฐ ์ง์ ๋์์ผ๋ฉฐ Ant ์คํ์ผ ํ์ด์ง์์ ์ด ์์ ์ ์ํํ ์ ์์ต๋๋ค.
function AntPage() => <div className="antPage">...</div>
๊ทธ๋ฌ๋ ์ด ๋ผ์ด๋ธ๋ฌ๋ฆฌ์์ ์ ๊ณตํ๋ ์ผ๋ถ ๊ตฌ์ฑ ์์๊ฐ ๋ค์์คํ์ด์ค ์คํ์ผ์ ์ค์ ๋ก ๋์ฒํ ์ ์๊ธฐ ๋๋ฌธ์ ๋ ๋ค๋ฅธ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.(
์๋ฅผ ๋ค์ด DatePicker
๊ฒฐ๊ณผ ๊ตฌ์ฑ ์์๊ฐ ๋ด๋ถ๋์ง ์๋๋ก, ๋งํฌ ์
_outside_ ๋ชธ์ ๋ ๋๋ง .antPage
๋ฐ๋ผ์ ์คํ์ผ์ด ์๋ํ์ง ์์ต๋๋ค. ์๋ํ๊ธฐ ์ํด ์ถ๊ฐ ๋งํฌ์
์ด ํ์ํ ๋๋กญ๋ค์ด ๋ฐ ๊ธฐํ ๊ตฌ์ฑ ์์์ ๊ฒฝ์ฐ์๋ ๋์ผํฉ๋๋ค.
๊ทธ๋ฐ ๋ค์ ์์์ ์ ์ํ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์๋ํ๋ฉด:
import 'antd/es/date-picker/style/index.css'
import 'antd/es/dropdown/style/index.css'
import 'antd/es/input/style/index.css'
๊ทธ๊ฒ์ _๊ฑฐ์_ ์๋ํ์ง๋ง ์ด์ํ๊ฒ ๋์ํ๊ธฐ ์์ํฉ๋๋ค. ๋ ์ง ์ ํ๊ธฐ์ ์ด์ ์ ๋ง์ถ๋ฉด ํ์๋์ง ์๊ณ ๋์ opacity: 0
๋จ์ ์์ต๋๋ค. ๊ทธ๋ฌ๋ค ์ด์ ์ ์๋ ์๊ฐ ๋ถ๋ ๋ ์ง ์ ํ๊ธฐ๊ฐ ๋ํ๋ฉ๋๋ค... ๐
์คํ์ผ์ ๊ฐ๋ณ์ ์ผ๋ก ๋ก๋ํ๋ ๊ฒ์ด ๋์์ ์ด๋ค ์ํฅ์ ๋ฏธ์น๋์ง ์ ํํ ํ์ ํ ์ ์์ง๋ง ๋ค๋ฅธ ๋ฒ๊ทธ์ผ ์ ์์ต๋๋ค.
์ด์จ๋ ๋น์ ์ญ ์คํ์ผ ๋ฒ์ ์ด ์ข์ ํจ๊ณผ๋ฅผ ๋ผ ์ ์๋์ง ๋ด ์๋ค :+1:
@OscardR ์ ๋ ์ด ๋ฌธ์ ๊ฐ ๋ชจ์
CSS ํ์ผ <strong i="6">@import</strong> 'antd/es/style/core/motion.less';
ํฌํจํ์ง ์์ ๊ฒ๊ณผ ๊ด๋ จ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
๋ค๋ฅธ ์ฌ๋์ด ๋น์ทํ ๋ฌธ์ ๊ฐ ์๊ณ ๋ชจ๋ ์คํ์ผ์ ๊ฐ์ ธ์ค์ง๋ง ์ ์ญ ์คํ์ผ์ด ์๋ ๊ฒฝ์ฐ:
๋ชจ๋ .less
ํ์ผ์ ๊ฐ์ ธ์์ antd.less
ํ์ผ์ ๋ฃ์ ๋ค์ ์ ์ญ ์คํ์ผ์ ํฌํจํ๋ dist ํ์ผ ๋์ ํด๋น ํ์ผ์ ๊ฐ์ ธ์ต๋๋ค.
https://gist.github.com/SPDUK/b93e9c28c11e41d5f3b6d9ad9fc7be36
๋ด๊ฐ ๋ ์ฌ์ฉ์๊ฐ ์๋ ๊ฒฝ์ฐ ๋ค๋ฅธ ์ต์ ์ ์ฌ์ฉํ ์ ์์ต๋๊น? ๋๋ sass๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ์ด๊ฒ์ ํจ์นํ๊ธฐ ์ํด ๋ ์ ๊ฒ ์ถ๊ฐํ๊ณ ์ถ์ง ์์ต๋๋ค. Select ๊ตฌ์ฑ ์์๋ฅผ ์คํํ๊ธฐ ์ํด ์ต์ํ์ CSS ํ์ผ๋ง ๋ก๋ํ ์ ์๊ธฐ๋ฅผ ์ํฉ๋๋ค.
๊ฑฐ์ 3๋ ๋์ ์ด ๋ฌธ์ ๊ฐ ๋ด Github ํํ์ด์ง ์๋จ์ ๋ํ๋ฉ๋๋ค.
๋๋ ์ด์ ์ค๋ซ๋์ ๊ฐ๋ฏธ ์ฌ์ฉ์ ์ค๋จํ์ต๋๋ค. ์ด๊ฒ์ ๋ซ๊ณ ์ปค๋ฎค๋ํฐ๋ ์ ์ง ๊ด๋ฆฌ์๊ฐ ๋ค๋ฅธ ๊ณณ์์ ํ๋ก์ฐํ๋๋ก ํ ์ ์์ต๋๊น?
Remove global Styles
์ ๋ํ ๋ชจ๋ ๊ฒ, ๋ชจ๋๊ฐ ์ด์ ์ด๊ฒ์ ์ง์คํ๊ณ ์์ต๋๋ค. ๋ ์์ธํ ์๊ณ ์ถ์ง ์๋ค๋ฉด ์ด ๋ฌธ์ ๋ง unsubscribe
ํ์ธ์. ๊ฐ์ฌํฉ๋๋ค!
์ต๊ณ ์ ์์ด๋์ด๊ฐ ์๋๊ฐ ์ถ์ต๋๋ค. ์ฐ๋ฆฌ ์ค ๋ง์ ์ฌ๋๋ค์ด ์ฌ์ ํ antd๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ์ด ๋ฌธ์ ๊ฐ ํด๊ฒฐ๋๊ธฐ๋ฅผ ๋ฐ๋๋๋ค.
์ฃผ์ ๋ฌธ์ ๊ฐ ๋ชจ๋ ์ญ์ฌ๋ฅผ ๊ฐ์ง๊ณ ์๋ค๋ ๊ฒ์ด ์ข์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ ํ์ธ์!
๋ค๋ฅธ ๋ฐฉ์์ผ๋ก ๊ตฌ์ฑ ์์ ์คํ์ผ์ ๊ฐ์ ธ์์ ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ์ต๋๋ค.
์ฒ์์๋ ๋ค์๊ณผ ๊ฐ์ ์คํ์ผ์ ๊ฐ์ ธ์์ต๋๋ค.
import 'antd/lib/button/style/css';
๊ทธ๋ฌ๋
css.js
๋ ๊ฐ์ ธ์ค๊ธฐ ๋ฒํผ์ ์คํ์ผ๋ฟ๋ง ์๋๋ผ ์ผ๋ฐ ์คํ์ผ๋ ๊ฐ์ ธ์ค๋ ๋ด์ฉ์ ๋๋ค.๊ทธ๋์ ๋ค์๊ณผ ๊ฐ์ด
index.css
ํ์ผ์ ๊ฐ์ ธ์์ ํด๊ฒฐํ์ต๋๋ค.import 'antd/lib/button/style/index.css';