๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Lect & Tip/vscode

vscode scss compiler sass ์‚ฌ์šฉํ•˜๋Š”๋ฒ• .mapํŒŒ์ผ์ด ์ƒ์„ฑ๋˜์ง€ ์•Š๊ฒŒ ์„ค์ •

by ๋‚ฏ์„ ๊ณต๊ฐ„2019 2023. 8. 30.

๋ชฉ์ฐจ

    vscode scss compiler VSCode์—์„œ SCSS ์ปดํŒŒ์ผ ๋ฐ .map ํŒŒ์ผ ์ƒ์„ฑ ๋ฐฉ์ง€ ์„ค์ •

    ๋ถ€์ œ: ๊ฐ„ํŽธํ•˜๊ฒŒ SCSS๋ฅผ ์ปดํŒŒ์ผํ•˜๊ณ  .map ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜์ง€ ์•Š๋Š” ๋ฐฉ๋ฒ•


    ์•ˆ๋…•ํ•˜์„ธ์š”, ์—ฌ๋Ÿฌ๋ถ„! ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„œ๋Š” Visual Studio Code(VSCode)์—์„œ SCSS(Sassy CSS)๋ฅผ ๊ฐ„ํŽธํ•˜๊ฒŒ ์ปดํŒŒ์ผํ•˜๊ณ , ๋ถˆํ•„์š”ํ•œ .map ํŒŒ์ผ ์ƒ์„ฑ์„ ๋ฐฉ์ง€ํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ ์ž‘์„ฑ ํ™˜๊ฒฝ์„ ๋”์šฑ ํšจ์œจ์ ์œผ๋กœ ๋งŒ๋“ค์–ด๋ณด์„ธ์š”.

    ํ•„์š”ํ•œ ํ™•์žฅ(extension)

    ๋‹ค์Œ๊ณผ ๊ฐ™์€ ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ์„ ์„ค์น˜ํ•˜๋ฉด SCSS ์ปดํŒŒ์ผ ๋ฐ .map ํŒŒ์ผ ๊ด€๋ฆฌ๊ฐ€ ํ›จ์”ฌ ๊ฐ„ํŽธํ•ด์ง‘๋‹ˆ๋‹ค.

    • Sass
    • Sass Lint
    • Live Sass Compiler
    • Live Server

    ์ด์ œ ์ค€๋น„๊ฐ€ ๋˜์…จ๋‹ค๋ฉด, ์‹œ์ž‘ํ•ด๋ด…์‹œ๋‹ค!

    SCSS ํŒŒ์ผ ์ปดํŒŒ์ผํ•˜๊ธฐ

    VSCode์—์„œ SCSS ํŒŒ์ผ์„ ์ปดํŒŒ์ผํ•˜๋ ค๋ฉด, ์•„๋ž˜์™€ ๊ฐ™์€ ๋‹จ๊ณ„๋ฅผ ๋”ฐ๋ฅด์„ธ์š”.

    1. VSCode ํ•˜๋‹จ์—์„œ "Live Sass Compiler" ์•„์ด์ฝ˜์„ ์ฐพ์Šต๋‹ˆ๋‹ค.
    2. ํ•ด๋‹น ์•„์ด์ฝ˜์„ ํด๋ฆญํ•˜์—ฌ ํ™œ์„ฑํ™”ํ•ฉ๋‹ˆ๋‹ค.
    3. ์ด์ œ ์‚ฌ์šฉํ•˜๊ณ ์ž ํ•˜๋Š” SCSS ํŒŒ์ผ์„ ์„ ํƒํ•œ ํ›„, "Watch Sass"๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.
    4. ์ปดํŒŒ์ผ ๋œ CSS ํŒŒ์ผ๊ณผ .map ํŒŒ์ผ์ด ๋™์ผํ•œ ๊ฒฝ๋กœ์— ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.

    .map ํŒŒ์ผ ์ƒ์„ฑ ๋ฐฉ์ง€ํ•˜๊ธฐ

    ๋ถˆํ•„์š”ํ•œ .map ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜์ง€ ์•Š์œผ๋ ค๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์„ค์ •ํ•˜์„ธ์š”.

    1. File > Preferences > Settings๋กœ ๋“ค์–ด๊ฐ‘๋‹ˆ๋‹ค.
    2. settings.json ํŒŒ์ผ์„ ์ฐพ์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ ํŒŒ์ผ์„ ์ฐพ๊ธฐ ์–ด๋ ต๋‹ค๋ฉด, ๊ฒ€์ƒ‰ ๊ธฐ๋Šฅ์„ ํ™œ์šฉํ•ด๋„ ์ข‹์Šต๋‹ˆ๋‹ค.
    3. ์•„๋ž˜ ์ฝ”๋“œ๋ฅผ settings.json ํŒŒ์ผ์— ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.
    {
      "liveSassCompile.settings.formats": [
        {
          "format": "expanded",
          "extensionName": ".css",
          "savePath": "~/../css"
        }
      ],
      "liveSassCompile.settings.excludeList": [
        "**/node_modules/**",
        ".vscode/**"
      ],
      "liveSassCompile.settings.generateMap": false,
      "liveSassCompile.settings.autoprefix": ["> 1%", "last 2 versions"],
      "editor.fontSize": 14,
      "editor.renderWhitespace": "all",
      "editor.wordWrap": "on",
      "emmet.triggerExpansionOnTab": true,
      "editor.tabCompletion": "on"
    }
    1. ์„ค์ •์„ ์ €์žฅํ•œ ํ›„, SCSS ํŒŒ์ผ์„ ๋‹ค์‹œ ์ €์žฅํ•˜๋ฉด ์ปดํŒŒ์ผ๋œ CSS ํŒŒ์ผ๊ณผ .map ํŒŒ์ผ์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. .map ํŒŒ์ผ ์ƒ์„ฑ์„ ๋ฐฉ์ง€ํ•˜๋ ค๋ฉด generateMap์„ false๋กœ ์„ค์ •ํ•˜์‹ญ์‹œ์˜ค.

    ๋งˆ๋ฌด๋ฆฌ

    ์ด์ œ ์—ฌ๋Ÿฌ๋ถ„์€ VSCode์—์„œ SCSS ํŒŒ์ผ์„ ๊ฐ„ํŽธํ•˜๊ฒŒ ์ปดํŒŒ์ผํ•˜๊ณ , ๋ถˆํ•„์š”ํ•œ .map ํŒŒ์ผ ์ƒ์„ฑ์„ ๋ฐฉ์ง€ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ์„ค์ •์„ ํ†ตํ•ด ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ๋”์šฑ ํšจ์œจ์ ์œผ๋กœ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ฌธ์ œ ํ•ด๊ฒฐ ๊ณผ์ •๊ณผ ํŒ์„ ๊ณต์œ ํ•ด๋“œ๋ฆฐ ์ด ๊ธ€์ด ์—ฌ๋Ÿฌ๋ถ„์˜ ๊ฐœ๋ฐœ ๋ฃจํ‹ด์— ๋„์›€์ด ๋˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค.

    ์ฃผ์˜์‚ฌํ•ญ

    • ๋ณธ ๊ธ€์€ ๋…์ž๋“ค์—๊ฒŒ ๋„์›€์„ ์ œ๊ณตํ•˜๊ธฐ ์œ„ํ•ด ์ž‘์„ฑ๋˜์—ˆ์œผ๋ฉฐ, ๋ณธ์ธ์˜ ๊ฒฝํ—˜๊ณผ ์—ฐ๊ตฌ ๊ฒฐ๊ณผ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ํ•ฉ๋‹ˆ๋‹ค.
    • ์‚ฌ์šฉํ•œ ํ™•์žฅ ํ”„๋กœ๊ทธ๋žจ ๋ฐ ์„ค์ •์€ ์ž‘์„ฑ ์‹œ์ ์˜ ๊ฒƒ์œผ๋กœ, ์ถ”ํ›„ ์—…๋ฐ์ดํŠธ์— ๋”ฐ๋ผ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ์ด๋กœ์จ SCSS ์ปดํŒŒ์ผ๊ณผ .map ํŒŒ์ผ ์ƒ์„ฑ ๋ฐฉ์ง€ ์„ค์ •์— ๋Œ€ํ•œ ๋‚ด์šฉ์„ ์†Œ๊ฐœ๋“œ๋ ธ์Šต๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ๋ถ„์˜ ๊ฐœ๋ฐœ ์ž‘์—…์„ ๋ณด๋‹ค ํšจ์œจ์ ์œผ๋กœ ์ˆ˜ํ–‰ํ•  ์ˆ˜ ์žˆ๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์ธ ๊ถ๊ธˆํ•œ ์‚ฌํ•ญ์ด๋‚˜ ์งˆ๋ฌธ์ด ์žˆ๋‹ค๋ฉด ์–ธ์ œ๋“ ์ง€ ๋ฌธ์˜ํ•ด์ฃผ์„ธ์š”. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

    ๋ฐ˜์‘ํ˜•

    ๋Œ“๊ธ€