์ฌ๋ฌ ํ์ด์ง์์ ๊ตฌ์ฑ ์์๋ฅผ ์ฌ์ฉํ๋ ์์ฉ ํ๋ก๊ทธ๋จ์ด ์์ต๋๋ค. ํ๋ก์ ํธ๋ฅผ ๋น๋ ํ ๋ ๊ตฌ์ฑ ์์์ ์คํ์ผ์ด ๊ฐ ๊ด๋ จ CSS ํ์ด์ง ์ฒญํฌ์ ๋ณต์ ๋ฉ๋๋ค. ์ด๊ฒ์ ์๊ฐ์ ๋ฒ๊ทธ๋ฅผ ๋ง๋ญ๋๋ค.
์๋ฅผ ๋ค์ด ( some-component
๋ฐ initial-page-component-override
๋ ์ด๊ธฐ ํ์ด์ง์ DOM์์ ๋์ผํ ์์์ ์ ์ฉ๋๋ ํด๋์ค์
๋๋ค) :
initial-page.chunk.css
// component styles
.some-component { margin-bottom: 10px; }
// page specific override
.initial-page-component-override { margin-bottom: 20px; }
second-page.chunk.css
// component styles
.some-component { margin-bottom: 10px; }
second-page.chunk.css๊ฐ DOM์ ์ถ๊ฐ๋๋ฉด ๊ตฌ์ฑ ์์ ์คํ์ผ์ด ์ด๊ธฐ ํ์ด์ง์ ์ ์ ๋ ๋ชจ๋ ํ์ด์ง ํน์ ์คํ์ผ์ ๋งจ ์์ ๋ค์ ์ ์ฉ๋ฉ๋๋ค. ์ฌ์ ์๊ฐ ์์ค๋๊ณ ์๋ชป๋ ์ฌ๋ฐฑ์ด ์ด์ ์ด๊ธฐ ํ์ด์ง์ ๊ตฌ์ฑ ์์์ ์ ์ฉ๋ฉ๋๋ค. NB ์ด๊ฒ์ ๊ฐ๋ฐ ๋ชจ๋์์๋ ๋ฌธ์ ๊ฐ ์๋๋ฉฐ ํ๋ก๋์ ์์๋ง ๋ฐ์ํฉ๋๋ค.
๋์์ ์ฌํํ๋ ๋จ๊ณ, ์ฝ๋ ์กฐ๊ฐ ๋๋ ์ ์ฅ์๋ฅผ ์ ๊ณตํ์ญ์์ค.
npm i
, npm run build
, npm start
์คํ์ผ ์ ์ธ์ ์ปดํ์ผ ๋ ์คํ์ผ ์ํธ์์ ์ค๋ณต๋์ง ์์์ผํฉ๋๋ค. ๊ตฌ์ฑ ์์ ์คํ์ผ์ ํ์ด์ง ๋ณ ์คํ์ผ ์์๋ก๋๋์ด์ผํฉ๋๋ค (์์ฒด ์ฒญํฌ์์?).
์ ํํ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค : https://github.com/zeit/next.js/issues/11946#issuecomment -615298112
์ฌ๊ธฐ์๋ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
๋๋ ์ฌ๊ธฐ์ ๋ด ๋ฌธ์ ๋ฅผ ์ค๋ช
ํ๋ค : https://github.com/zeit/next.js/pull/11901#issuecomment -614644961
์ง์ ์ด ์์ต๋๊น? ๋๋ ์ฌ์ ํ ๋๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฐ์ง๊ณ ์์ผ๋ฉฐ ๊ทธ๊ฒ์ ํ๋ก๋์
์ ๋ฃ์ ์ ์์ต๋๋ค.
9.3.7-canary.9
์์ ํ
์คํธ ๋จ
์๋
ํ์ธ์.
์ํ : v9.3.7-canary.11 ๋ฐ ๋ฌธ์ ๊ฐ ์ฌ์ ํ ์ง์๋ฉ๋๋ค.
monorepo์์๋ ๊ณต์ ๊ตฌ์ฑ ์์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ ๊ตฌ์ฑ ์์์ ๋น์ทํ ๋ฌธ์ ๊ฐ์๋ ๊ฒ ๊ฐ์ต๋๋ค. ์ด๋ฌํ ๊ตฌ์ฑ ์์์ ์ํฅ์์ฃผ๋ ์ฑ์ ๋ชจ๋ ์คํ์ผ์ ์ฑ CSS ํ์ผ์ ์คํ์ผ์ ํน์์ฑ์ด ๋ ๋์ผ๋ฏ๋ก ์ฐ์ ํด์ผํฉ๋๋ค. ๊ฐ๋ฐ ๋ชจ๋์์๋ ๊ด์ฐฎ์ ๋ณด์ด์ง๋ง ํ๋ก๋์ ์ด ์๋๋๋ค.
(์ฐ๋ฆฌ๋ @zeit/next-sass
์ ํจ๊ป SCSS ๋ชจ๋์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค)
@ zeit / next-sass ๋๋ @ zeit / next-css๋ฅผ ์ฌ์ฉํ ๋ ๋ชจ๋ ๊ฒ์ด ์์, ์ ํธ๋ ๋ฐ ๋ฉ์ด๋ฆฌ ์ฌ์ด์ ์ค๋ณต์ผ๋ก ๊ฝค ๊ด์ฐฎ ์์ต๋๋ค. :์๊ฐ:
๋์๊ฒ ์ง์ง ๋ฌธ์ ๋ nextjs๋ฅผ 9.3์ผ๋ก ์ ๋ฐ์ดํธํ๊ณ CSS ๋ชจ๋์ ์ฌ์ฉํ๊ธฐ ์์ํ์ ๋ ์์๋ฉ๋๋ค.
๋๋ ๋ ๊ฐ์ง ๋ฐฉ๋ฒ (next-sass ๋ฐ built-in)์ ๋ชจ๋ ์๋ํ์ต๋๋ค. ๋ ๊ฒฝ์ฐ ๋ชจ๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค.
๋ด ์คํ :
1) CSS ๋ชจ๋
2) SCSS
3) @use ๊ฐ์ ธ ์ค๊ธฐ ๊ธฐ๋ฅ์ด์๋ Dart-Sass
๋ง์ ๋ณํ์ ์๋ํ๊ณ ์ด๊ฒ์ ๋๋ฅผ ์ํด ์๋ํฉ๋๋ค (์คํ์ผ ์ค๋ณต ์์).
1) package.json :
"@zeit/next-css": "^1.0.1",
"@zeit/next-sass": "^1.0.1",
"next": "9.2.1", (9.4.1 is current)
"node-sass": "npm:[email protected]", (this is dart sass, but can be used default)
2) next.config.js
const path = require('path')
const withSass = require('@zeit/next-sass')
const withCSS = require('@zeit/next-css')
const withBundleAnalyzer = require('@next/bundle-analyzer')({ // Optional, of course
enabled: process.env.ANALYZE === 'true',
})
module.exports = withBundleAnalyzer(
withCSS(
withSass({
cssModules: true,
sassLoaderOptions: {
// Resolving SASS absolute imports
includePaths: [path.resolve(__dirname, 'src')],
},
cssLoaderOptions: {
importLoaders: 2,
localIdentName:
process.env.NODE_ENV === 'production'
? '[hash:base64]'
: '[name]__[local]__[hash:base64:5]',
},
webpack(config, options) {
// Resolving absolute imports
config.resolve.modules.push(path.join(__dirname, 'src'))
// Make global styles work
config.module.rules.forEach(rule => {
if (rule.test && rule.test.toString().includes('.scss')) {
rule.rules = rule.use.map(useRule => {
if (typeof useRule === 'string') {
return {
loader: useRule,
}
}
if (useRule.loader.startsWith('css-loader')) {
return {
oneOf: [
{
test: new RegExp('.module.scss$'),
loader: useRule.loader,
options: useRule.options,
},
{
loader: useRule.loader,
options: {},
},
],
}
}
return useRule
})
delete rule.use
}
})
return config
},
}),
),
)
3) ๋ค์๊ณผ ๊ฐ์ ๊ธ๋ก๋ฒ (๋ชจ๋์ด ์๋) ์คํ์ผ ๊ฐ์ ธ ์ค๊ธฐ :
index.scss :
...
<strong i="19">@import</strong> '~emoji-mart/css/emoji-mart.css';
...
๋๊ตฐ๊ฐ ์ด๋ฌํ ๊ตฌ์ฑ์ ์๋ํ๋ฉด ์ข์ ๊ฒ์ด๋ฏ๋ก ์ด๊ฒ์ด ์ค์ ๋ก ์๋ํ๋์ง ํ์ธํ ์ ์์ต๋๋ค.
๋๋ ์ด๊ฒ์ ๊ต์ฒดํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
.other-page__component-override { background: pink; }
์ด๊ฒ์ผ๋ก :
.other-page .component-override { background: pink; }
๋ฐ๋ผ์ ํ์ด์ง ๋ณ ์คํ์ผ์ ํด๋น ํน์ ํ์ด์ง์๋ง ์ ์ฉ๋ฉ๋๋ค =).
์ด ๋ฒ๊ทธ์๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
๋ค์ css๋ฅผ ๋ด์ฅ css๋ก ๋ณ๊ฒฝํ๋๋ฐ ๋ฐ์ํ์ต๋๋ค.
๊ฐ๋ฐ ๋ชจ๋์์๋ ์๋ํ์ง๋ง CSR์ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ ํ๋ก๋์
๋ชจ๋์์๋ ์๋ํ์ง ์์ต๋๋ค. SSR์์๋ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
๋๋ ๋ด์ฅ CSS ์ง์๊ณผ ํจ๊ป ๋ค์ 9.4.4๋ฅผ ์ฌ์ฉํ๊ณ ๋๋์ด ๋ฌธ์ ๊ฐ ์์ผ๋ฉฐ ํ๋ก๋์ ์์ ๋ฐ์ํฉ๋๋ค.
๋ค์ 9.4.4์์ ๋์ผํ ๋ฌธ์ . ํ๋ก๋์ ๋ชจ๋์์๋ง
์ด๊ฒ์ ๋ค์ 9.4.4์ ํ๋ก๋์ ํ๊ฒฝ์์ ๋ฐ์ํ๋ฉฐ ์ด๋ป๊ฒ ๋ ํด๊ฒฐ์ฑ ์ ์ฐพ์์ต๋๋ค.
node-sass
๋ฅผ ์ฌ์ฉํ์ฌ ๋ฌธ์์์ ๋ค์ํ ์ต์
์ ์๋ํ๊ณ next.config.js
์ sassOptions
๋ฅผ ์ถ๊ฐํ์ฌ์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํฉ๋๋ค.
module.exports = {
...,
sassOptions: {
outputStyle: 'expanded',
},
}
์ฐธ์กฐ : outputStyle
next build
ํ CSS ํด๋์ค ์ด๋ฆ์ ํ์ธํ ํ ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค.
๋์์ด ๋์๊ธฐ๋ฅผ ๋ฐ๋๋๋ค!
@ Howard86 ์ ๊ณต์ ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค. ์๋ํ์ง๋ง ์ฌ๊ธฐ์๋ ์๋ํ์ง ์์์ต๋๋ค. ์ฐ๋ฆฌ๋ ๋น๋์์๋ next-css์ next-sass๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค (Next์ ๋ด์ฅ CSS ์ง์์ด ์๋๋ฉฐ์ด ๋ฌธ์ ์ ์ค๋ช ๋ ๋์ผํ ๋ฌธ์ ๊ฐ ์์). ๋ณต์ ๋ css๋ก ๊ฐ์ ธ์จ ์์ CSS์์ ์ค๋ ํด๋์ค์์ ๋ฐ์ํฉ๋๋ค. sass ์คํ์ผ์์ ์ค์ง ์๋ ๋ชจ๋
@ Howard86 @ ์๋ ์ฐ๋๋ฅด-marchina
๋๋ ๋ค์ 9.4.4์์ ๋ด์ฅ CSS๋ฅผ ์ฌ์ฉํ๊ณ ์์ผ๋ฉฐ ๊ทํ์ ์๋ฃจ์ ๋ ๋์๊ฒ ํจ๊ณผ๊ฐ ์์ต๋๋ค. :์ธ์ ์๋ฆฌ:
๋๋ antd์ ๋ค์ ์ต์ ๐๊ณผ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
๊ฐ์ ๋ฌธ์ . css๋ dev์์ ์๋ฒฝํ๊ฒ๋ก๋๋์ง๋ง ์ ํ์์๋ ์ผ๋ถ css ์ฒญํฌ๊ฐ๋ก๋๋์ง ์์ต๋๋ค.
์ฌ๊ธฐ์์๋ ๊ฐ์ ๋ฌธ์ ์ ๋๋ค.
prod ๋น๋์์ ๋ค์ v9.5.1์์ ๋์ผํ ๋ฌธ์ ๋ฅผ ๊ฒฝํํ์ผ๋ฉฐ dev ๋น๋์์ ์คํ์ผ์ ๊ด์ฐฎ์ต๋๋ค.
์ด ๋ฒ๊ทธ๋ next.js์์ css-modules๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํ๊ฒ ๋ง๋ญ๋๋ค (์๋ฌด๋ ์คํ์ผ์! important๋ฅผ ์ถ๊ฐํ๊ณ ์ถ์ดํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค)
์ด ๋ฒ๊ทธ๋ next.js์์ css-modules๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ ๋ถ๊ฐ๋ฅํ๊ฒ ๋ง๋ญ๋๋ค (์๋ฌด๋ ์คํ์ผ์! important๋ฅผ ์ถ๊ฐํ๊ณ ์ถ์ดํ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ค)
๊ธฐ๋ณธ ์คํ์ผ์ ์ฌ์ ์ํ๋ ์คํ์ผ์ ๋ํ ํน์์ฑ์ ๋์ผ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, Button <-IconButton <-MoreSpecificButton๊ณผ ๊ฐ์ ๊ตฌ์ฑ ์์ ์ข
์์ฑ์ ๊ฐ์ต๋๋ค. ์ด ๊ฒฝ์ฐ Button์๋ ๋ค๋ฅธ ํ์ด์ง๋ก ์ ํ ํ ๋ ๋ค์๋ก๋๋๋ ์์ฒด ์คํ์ผ์ด ์์ผ๋ฏ๋ก IconButton ๋ฐ MoreSpecificButton์ ์คํ์ผ์ ์ฌ์ ์ํฉ๋๋ค. IconButton๊ณผ ๊ฐ์ด ์ ์์ ์คํ์ผ์ด์๋ ๊ฒฝ์ฐ .className.className
, ๊ทธ๋ฆฌ๊ณ MoreSpecificButton๋ ๋ฑ์ ์คํ์ผ์ด .className.className
๋๋ฌด ๋ค์ ๋ฒํผ์ ์ค๋ฒ๋ผ์ด๋ (override)ํ์ง ์์ต๋๋ค. ๊ทธ๋ฆฌ๊ณ IconButton ๋ฐ MoreSpecificButton ์คํ์ผ์ ์์๊ฐ CSS์์ ์ ํํ๋ค๋ ์ฌ์ค์ ์๊ณ ์์ผ๋ฉด MoreSpecificButton์ ์คํ์ผ์ ํญ์ IconButton์ ์ฌ์ ์ํฉ๋๋ค.
prod ๋น๋์์ ๋ค์ v9.5.1์์ ๋์ผํ ๋ฌธ์ ๋ฅผ ๊ฒฝํํ์ผ๋ฉฐ dev ๋น๋์์ ์คํ์ผ์ ๊ด์ฐฎ์ต๋๋ค.
๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
Tailwind, Bootstrap์ +1. ํ์ฌ ํด๊ฒฐ ๋ฐฉ๋ฒ์ _document.js์ link rel์ ํตํด ๋ชจ๋ ์คํ์ผ์ ๊ฐ์ ธ ์ค๋ ๊ฒ์ ๋๋ค. Tailwind์ ๊ฒฝ์ฐ ์ฌ์ฉ์ ์ง์ CSS ๋น๋์ ๋๋ค. ์ด ๋ฌธ์ ๋ ๋งค์ฐ ์ฑ๊ฐ์๋ค.
๋๋ tailwind (์ผ๋ฐ ์ ์ญ CSS ๊ฐ์ ธ ์ค๊ธฐ)์ ํจ๊ป CSS ๋ชจ๋์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ์ธ๋ผ์ธ CSS๋๋ก๋ ์์๋ฅผ ํด๊ฒฐํ์ง๋ง ์ฌ์ ํ ๋ณต์ ์ค์ธ์ง ๋ชจ๋ฅด๊ฒ ์ง๋ง ํด๊ฒฐ ๋ฐฉ๋ฒ ์ผ๋ฟ์ ๋๋ค. ํ๋ก๋์ ์์๋ ์คํ์ผ์ด ๋ค๋ฅธ ์คํ์ผ๋ณด๋ค ์ฐ์ ํ๋ ๊ฒ์ ์์ ์ฐจ๋ฆฌ์ง ๋ชปํ์ต๋๋ค.
https://github.com/vercel/next-plugins/issues/238#issuecomment -432211871
์ด๊ฒ์ ์ต์ Next.js ์นด๋๋ฆฌ์์์ ์์ ๋์์ต๋๋ค. next@^9.5.3-canary.7
์
๊ทธ๋ ์ด๋ํ์ฌ ์๋ ค์ฃผ์ธ์!
์๋ฅผ ๋ค์ด ๋ผ์ธ ๋์ด, ๊ธ๊ผด ๋๊ป, ๋ฐฐ๊ฒฝ์, ํ ๋๋ฆฌ๊ฐ dev์ prod์์ ๋ค๋ฆ ๋๋ค.
@talaikis ๊ทธ๋ผ ์์ ํ ์ฌํ ๊ฐ๋ฅํ ๋ฐ๋ชจ๋ก ์ ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์! ์ด ๋ณต์ ํ์ ์ ๊ณต๋ ์ ํํ ์ฝ๋์ canary
์ง๊ธ ํ
์คํธํ์ต๋๋ค.
๋์๊ฒ ๊ณ ์น์ง ๋ง ๋ ๋ค๋ฅธ ์ค์ํ ๋ฌธ์ ๊ฐ ๋ฐ์ํฉ๋๋ค.
์ ๊ฒฝ์ฐ์๋ Router.push(
localhost : 3000 / # change ) coming from
localhost : 3000` ๋ชจ๋ ์คํ์ผ ์ํธ๊ฐ ๋ค์๋ก๋๋์ด ํ๋ฉด์ด ๊น๋ฐ์ด๋ ์์ธ์ด๋๋ ํด์ URL ๋ง ๋ณ๊ฒฝํฉ๋๋ค.
9.5.3-canary.9
์๋ํด ์ฃผ์๊ฒ ์ต๋๊น?
@Timer ์คํ npm i
:
๋๋ 9.5.3-canary.9
์๋ํ์ง๋ง ์ฌ์ ํ ํด์ ๋ฌธ์ ๊ฐ ์ง์๋ฉ๋๋ค.
๋๋ ๊ทธ๊ฒ์ ์ธ๊ธํ์ง ์์์ง๋ง 9.5.2
ํ๊ณ ์์ผ๋ฉฐ 9.5.3-canary.6
๋ก ๋ง์ด๊ทธ๋ ์ด์
ํ์ ๋ ๋ผ์ฐํฐ๋ฅผ ์ฌ์ฉํ์ฌ ์์ ๊ฐ์ด ํด์๋ฅผ ๋ณ๊ฒฝํ๋ฉด devtools ์ฝ์์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค.
9.5.3-canary.5
.
@fabinppk ๋ณต์ ๋ก ์๋ก์ด ๋ฌธ์ ๋ฅผ ์ด์ด์ฃผ์ธ์!
์๋ ๋ฌธ์ ๊ฐ 9.5.3-canary.9
์์ ํด๊ฒฐ ๋ ๊ฒ์ผ๋ก ํ์ธํ๊ณ ์ถ์์ต๋๋ค. @Timer ๊ฐ์ฌํฉ๋๋ค
@petewarman์ ํ์ธํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค!
@Timer ํ์คํฉ๋๋ค. ๋๋ ๋น์ ์ ์์ ์ด ๊ด์ฐฎ๊ณ devtools ์์ด ๋ฌธ์ ์ ๊ด๋ จ์ด ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
๊ฐ์ฌํฉ๋๋ค. : +1 :
์ด๊ฒ์ด 9.5.6-canary.11
์์ ์ฌ์ ํ ์ผ์ด๋๊ณ ์์์ ํ์ธํ ์ ์์ผ๋ฉฐ, ํด๋์ค๋ ์ฒญํฌ์์ ์ค๋ณต๋ฉ๋๋ค.
@glottonous ์ด ๋ฌธ์ ์ ์ธ๊ธ ๋ ๋ชจ๋ ๋ฌธ์ ๋ ํ์ด๋จธ๋ก ํด๊ฒฐ๋์์ต๋๋ค.
์ถ์ : 9.5.5๋ฅผ ์ฌ์ฉํ๊ณ ์์ต๋๋ค. ๐๐
@fabinppk 9.5.6-canary.11
ํ์ฌ ๋์ผํ ๋ฌธ์ ๊ฐ ์ฌ์ ํ ๋ฐ์ํ๊ณ ์์์ ํ์ธํ ์ ์์ต๋๋ค.
@glottonous ๋ฒ์ 9.5.6-canary.11
๋ด ํ๋ก์ ํธ์ ๋ํ ๋ช ๊ฐ์ง ํ
์คํธ๋ฅผ ์ํํ๋๋ฐ ์๋ฌด๋ฐ ๋ฌธ์ ๊ฐ ์์์ต๋๋ค.
์ ๋ง๋ก ๋ฌธ์ ๊ฐ์๋ ๊ฒฝ์ฐ์ด ๋ฌธ์ ๋ฅผ ์ฐธ์กฐํ์ฌ ์ ๋ฌธ์ ๋ฅผ ์ฝ๋ ๋ค. : +1 :
nextjs 10์์ ๋์ผํ ๋ฌธ์
๊ฐ์ ๋ฌธ์ 10.0.1
์ฌํ ๊ฐ๋ฅํ ๋ฐ๋ชจ๋ก # 19055๋ฅผ ์์ํ์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์ ํํ ๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค : https://github.com/zeit/next.js/issues/11946#issuecomment -615298112