웹팩(webpack) config 와 mode

Nolec·2021년 8월 30일
0

웹팩 (webpack)

목록 보기
3/3
post-thumbnail

config 파일 생성

우리는 cli -> npx webpack --en~~ 요런걸로는 제대로 활용할 수 없다!!!!
즉 config를 이용하면 더욱더 멋지게 webpack을 활용할 수 있는 것!

  • webpack.config.js(기본적으로 npx webpack 실행시 이놈의 파일을 찾는다.) 생성
  • npx webpack --entry ./js/index.js --output ./dist/webpack_index.js 를 config 파일로 표현하자!
// webpack.config.js 파일

const path = require("path"); // 기본적으로 내장되어 있는 path(경로) 라이브러리

module.exports = {
  entry: "./js/index.js",
  output: {
  
    // __dirname -> 현재 파일의 위치(/Users/nolec/dev/webpack-learning)
    // path.resolve(__dirname, "dist") -> /Users/nolec/dev/webpack-learning/dist
    
    path: path.resolve(__dirname, "dist"),  
    filename: "webpack_index.js",
  },
};

그리고 npx webpack을 실행 시키면 결과는...?

잘 작동한다!!!!

mode 설정

  • 간단하게 위와 같이 설정하면 끝!

참고 : 생활코딩 webpack편

profile
노렉마지노

0개의 댓글