우리는 cli -> npx webpack --en~~ 요런걸로는 제대로 활용할 수 없다!!!!
즉 config를 이용하면 더욱더 멋지게 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를 설정해 달라는 이야기이다.
- https://webpack.js.org/configuration/mode/ 참고하면 mode에 대한 설명이 나와있다.
참고 : 생활코딩 webpack편