๐Ÿš€ ๊ฐœ์ธ ๋น„ + ์›น์šฉ ๋ฆฌ์•กํŠธ ๋„ค์ดํ‹ฐ๋ธŒ + ์—‘์Šคํฌ ๐Ÿฅณ

6518 ๋‹จ์–ด reactgatsbytutorialjavascript
์š”์•ฝ: ๐ŸŽณExample ๐Ÿ“šDocs



์ด ๊ฒŒ์‹œ๋ฌผ์—์„œ๋Š” ์›น์„ ํƒ€๊ฒŸํŒ…ํ•  ๋•Œ Gatsby์„ ์‚ฌ์šฉํ•˜๋„๋ก (๋ฒ”์šฉ) Expo ์•ฑ์„ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ณด์—ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค!

๐Ÿšจ If you find bugs please report them on the expo-cli repo with the [gatsby] tag in the title.



Gatsby๋ฅผ Expo์™€ ํ•จ๊ป˜ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋Š” ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?



์ด ์ž‘์—…์˜ ์ฃผ์š” ์ด์ ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • prerender ์•ฑ์˜ ์›น ํŒŒํŠธ๋ฅผ Expo ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์ด๋ฏธ Gatsby๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋‹ค๋ฉด ์ด์ œ ์›น๊ณผ ๋ชจ๋ฐ”์ผ ๊ฐ„์— ๋Œ€๋ถ€๋ถ„์˜ ์ฝ”๋“œ๋ฅผ ๊ณต์œ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Expo๋ฅผ ์ฒ˜์Œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ๋ธŒ๋ผ์šฐ์ €์—์„œ ๊ฐ€๋Šฅํ•  ๋•Œ๋งˆ๋‹ค ์นด๋ฉ”๋ผ, ์ œ์Šค์ฒ˜, ๊ถŒํ•œ ๋“ฑ๊ณผ ๊ฐ™์€ Expo SDK์˜ ๋ณต์žกํ•œ ๋ธŒ๋ผ์šฐ์ € ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Œ์„ ์˜๋ฏธํ•ฉ๋‹ˆ๋‹ค!

  • โšฝ๏ธ ํŠœํ† ๋ฆฌ์–ผ




  • Expo CLI ์„ค์น˜ ๋˜๋Š” ์—…๋ฐ์ดํŠธ: npm i -g expo-cli
  • ์ƒˆ ์—‘์Šคํฌ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ: expo init
  • Gatsby ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

  •   # yarn
      yarn add gatsby gatsby-plugin-react-native-web
    
      # npm
      npm install --save gatsby gatsby-plugin-react-native-web
    


  • gatsby-config.js๋ฅผ ๋งŒ๋“ค๊ณ  ํ”Œ๋Ÿฌ๊ทธ์ธ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    gatsby-config.js

  •    module.exports = {
         plugins: [
           `gatsby-plugin-react-native-web`,
           /* ... */
         ],
       }
    


  • /.cache ๋ฐ /public๋ฅผ .gitignore ์— ์ถ”๊ฐ€
  • ์ด์ œ Gatsby ํ”„๋กœ์ ํŠธ์˜ ์ฒซ ๋ฒˆ์งธ ํŽ˜์ด์ง€๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
  • ํŽ˜์ด์ง€ ํด๋” ๋งŒ๋“ค๊ธฐ: mkdir -p src/pages
  • ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.


  •   # JS
      cp App.js src/pages/index.js
    
      # TS
      cp App.tsx src/pages/index.tsx
    


  • yarn gatsby develop๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์‚ฌ์šฉํ•ด ๋ณด์‹ญ์‹œ์˜ค!
  • ๋ธŒ๋ผ์šฐ์ €์—์„œ ํ”„๋กœ์ ํŠธ ์—ด๊ธฐhttp://localhost:8000/




  • ๋ฌธ์ œ ํ•ด๊ฒฐ



    Expo CLI ์—†์ด ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•œ ๊ฒฝ์šฐ ๋‹ค์Œ ์ž‘์—…๋„ ์ˆ˜ํ–‰ํ•ด์•ผ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Gatsby CLI๋กœ ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•œ ๊ฒฝ์šฐ ๋ฌธ์„œ์— ์ž‘์„ฑํ•œ ๊ฐ€์ด๋“œ๋ฅผ ํ™•์ธํ•˜์‹ญ์‹œ์˜ค: Gatsby Project with Expo .
  • ์›น์šฉ React Native ์„ค์น˜: yarn add react-native-web
  • React Native ์›น์šฉ babel ์‚ฌ์ „ ์„ค์ •์„ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

  •   # yarn
      yarn add --dev babel-preset-expo
      # npm
      npm install --save-dev babel-preset-expo
    


  • ๐Ÿ’ก ์ด๋ฆ„์— Expo๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์ง€๋งŒ ๋ฒ”์šฉ ํ”Œ๋žซํผ ์ง€์›์„ ์ œ๊ณตํ•˜๋ฏ€๋กœ ๋ชจ๋“  React Native ํ”„๋กœ์ ํŠธ์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • babel.config.js๋ฅผ ๋งŒ๋“ค๊ณ  Babel ์‚ฌ์ „ ์„ค์ •์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
    babel.config.js


  •    module.exports = { presets: ['babel-preset-expo'] }
    


    ๐Ÿ ์ƒˆ๋กœ์šด ๋ช…๋ น



  • ์›น ์‹œ์ž‘
  • ๐Ÿšซ expo start:web
  • โœ… yarn gatsby develop



  • ์›น ๊ตฌ์ถ•
  • ๐Ÿšซ expo build:web
  • โœ… yarn gatsby build



  • ์ •์  ํ”„๋กœ์ ํŠธ ์ œ๊ณต
  • ๐Ÿšซ serve web-build
  • โœ… yarn gatsby serve


  • ๐Ÿ“ ํŒŒ์ผ ๊ตฌ์กฐ



    Gatsby๋ฅผ ์ง€์›ํ•˜๋Š” Expo ํ”„๋กœ์ ํŠธ์— ๊ถŒ์žฅ๋˜๋Š” ํŒŒ์ผ ๊ตฌ์กฐ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    Expo Gatsby
    โ”œโ”€โ”€ src
    โ”‚   โ””โ”€โ”€ pages โžก๏ธ Routes
    โ”‚       โ””โ”€โ”€ index.tsx โžก๏ธ Entry Point for Gatsby
    โ”œโ”€โ”€ .cache โžก๏ธ Generated Gatsby files (should be ignored)
    โ”œโ”€โ”€ public โžก๏ธ Generated Gatsby files (should be ignored)
    โ”œโ”€โ”€ assets โžก๏ธ All static assets for your project
    โ”œโ”€โ”€ App.tsx โžก๏ธ Entry Point for Mobile apps
    โ”œโ”€โ”€ app.json โžก๏ธ Expo config file
    โ”œโ”€โ”€ gatsby-config.js โžก๏ธ Gatsby config file
    โ””โ”€โ”€ babel.config.js โžก๏ธ Babel config (should be using `babel-preset-expo`)
    


    ๐Ÿ‘‹ ์ฝ์–ด์ฃผ์…”์„œ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค



    ์ด ๊ธฐ์‚ฌ๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์ด ์›Œํฌํ”Œ๋กœ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค๋ฉด ์–ด๋–ป๊ฒŒ ์ž‘๋™ํ–ˆ๋Š”์ง€ ๋“ฃ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค ๐Ÿ˜ ์‚ฌ์šฉํ•˜์ง€ ์•Š์•˜๋‹ค๋ฉด ๋“ฃ๊ณ  ์‹ถ์Šต๋‹ˆ๋‹ค! ๊ทธ๋Ÿฌ๋‹ˆ ์ €์—๊ฒŒ ์ด๋ชจํ‹ฐ์ฝ˜์„ ํŠธ์œ—ํ•ด๋ณด์„ธ์š” :)

    ๐Ÿ“š ์ถ”๊ฐ€ ์ •๋ณด


  • Expo support PR
  • Example
  • Docs
  • Tips and Tricks for React Native web

  • ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ