An warware: nextjs tare da iska mai wutsiya css da

Yin amfani da ilimin ฦ™wararrun mu, za mu iya fara labarin kamar haka:

NextJS sanannen tsari ne a cikin tsarin muhallin JavaScript saboda ฦ™arfin aikinsa da abubuwan haษ“aka kayan aiki. Haษ—e tare da Tailwind CSS, tsarin CSS na farko mai amfani, yana ba da tushe mai ฦ™arfi da sassauฦ™a don gina aikace-aikacen yanar gizo na zamani, ingantaccen inganci. Abin da ya fi dacewa shi ne dacewarsa tare da Typescript, wanda ke ba masu haษ“aka damar yin amfani da fa'idodi kamar buga rubutu a tsaye da yuwuwar gano kurakuran lokacin aiki.

Ta hanyar NextJS da Tailwind CSS, Masu haษ“akawa na iya kawo ra'ayoyin su zuwa rayuwa da inganci, suna ษ—aukar yawan aiki zuwa mataki na gaba. Tare, waษ—annan kayan aikin masu ฦ™arfi suna haifar da tsabta, daษ—aษ—ษ—a da ingantattun mu'amalar mai amfani.

Gabatarwar Matsala

Yawancin lokaci, masu haษ“akawa suna fuskantar ฦ™alubalen kafa NextJS tare da Rubutun Rubutun da Tailwind CSS. Wannan tsari yana buฦ™atar fahimtar ฦ™ididdiga daban-daban da daidaitawa. Koyaya, ka tabbata saboda mun samar da mafita mataki-mataki ga wannan matsala a cikin sakin layi na gaba, ta haka ne. sauฦ™aฦ™e muku wannan tsari.

// Basic imports 
import React from 'react';
import styled from 'styled-components';

const StyledDiv = styled.div`
    /* your styles here */
`;

class MyStyledComponent extends React.Component {
  render() {
    return <StyledDiv> /* your code here */ </StyledDiv>
  }
}

export default MyStyledComponent;

Mataki-mataki Neman Magani

Don daidaita tsarin saitin, yana da amfani a raba shi zuwa matakai masu iya sarrafawa.

Mataki 1: Fara da ฦ™addamar da sabon aikin NextJS:

npx create-next-app my-app
cd my-app

Mataki 2: Saita Rubutun Rubutun:

npm install --save typescript
touch tsconfig.json

Gudanar da uwar garken haษ“akawa tare da 'npm run dev'. NextJS zai saita fayil ษ—in 'tsconfig.json' ta atomatik ta atomatik.

Game da ฦ™ara Tailwind CSS zuwa NextJS, akwai hanyoyi guda biyu masu yiwuwa - shigar da shi da hannu ko amfani da plugin. Don aiwatarwa kai tsaye, muna ba da shawarar hanyar plugin.

Haษ—a Tailwind CSS tare da NextJS

Idan kuna canzawa daga saitin abubuwan da aka tsara ko kuma kawai kuna son haษ—a Tailwind CSS tare da NextJS, wannan sashin zai jagorance ku ta hanyar:

npm install tailwindcss @fullhuman/postcss-purgecss postcss-preset-env
npx tailwind init tailwind.config.js --full

Na gaba, saita PostCSS don amfani da Tailwind CSS da PurgeCSS, wanda ke inganta girman nauyin biya na ฦ™arshe yadda ya kamata. A ฦ™arshe, kar a manta ku haษ—a CSS na Tailwind a cikin salon ku na duniya.

Muhimman Dakunan karatu da Ayyuka

Dukansu NextJS da Tailwind CSS suna kawo ษ—akunan karatu da ayyuka da yawa don daidaita tsarin haษ“aka ku. Fitattun su ne 'styled-jsx' ษ—akin karatu na NextJS wanda ke ba da damar yin salo da yawa da kuma '@apply' aiki daga Tailwind CSS don tsara hadaddun bayyanuwa.

Buga haษ—awar Tailwind CSS tare da NextJS, ฦ™a'idodin gidan yanar gizon ku ya zama a shirye don haษ“aka kayan aikin. Wannan haษ—e-haษ—e, wanda aka tara tare da Typescript, yana haษ“aka tsarin haษ“aka ku sosai yayin sa aikace-aikacenku ya zama mai inganci da kiyayewa. Duk da haka, mabuษ—in yin amfani da waษ—annan kayan aikin yadda ya kamata ya ta'allaka ne cikin fahimtar amfani da su wajen haษ“aka na zamani, aikace-aikacen yanar gizo na abokantaka na SEO. Wannan shine inda ainihin kyawun NextJS, Tailwind CSS, da Nau'in Rubutun ya buษ—e.

Binciken da ke sama yana jagorantar ku akan kafa NextJS, Rubutun rubutu, da muhallin Tailwind CSS, kuma muna fatan ya gabatar da taswirar hanya mai mahimmanci a cikin tafiyar ci gaban yanar gizon ku.

Shafi posts:

Leave a Comment