강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

정재윤님의 프로필 이미지
정재윤

작성한 질문수

프론트엔드 개발환경의 이해와 실습 (webpack, babel, eslint..)

바벨(풀이)

webpack loader 관련 질문

작성

·

245

0

안녕하세요 정환님.

webpack loader 관련해서 질문이 있습니다.

 

// webpack.config.js

module: [

  rules: [

    {

       test: ~~~~,

이렇게 작성할 때,

  • loader: ~~~,
  • use: [~~]

두 가지 방식으로 작성하는 거 같은데요.

혹시 무슨 차이가 있을까요?

use : [{

  loader: ~~~,

  options: {...}

}]

이렇게도 작성하는 것 같더라고요

답변 1

0

김정환님의 프로필 이미지
김정환
지식공유자

하나의 로더만 설정할때는 loader와 options를 사용하고요. 두 개 이상 로더를 설정할 때는 use 옵션을 사용합니다.

// Actions:
loader: "babel-loader",
// the loader which should be applied, it'll be resolved relative to the context

options: {
  presets: ["es2015"]
},

// options for the loader
use: [
  // apply multiple loaders and options instead. 여러개 로더와 옵션을 사용할 때 
  "htmllint-loader",
  {
    loader: "html-loader",
    options: {
      // ...
    }
  }
],

설정 문서도 참고드립니다.

정재윤님의 프로필 이미지
정재윤

작성한 질문수

질문하기