Skip to content

resolve

박수정 edited this page Aug 15, 2024 · 2 revisions

resolve란?

공식 문서
웹팩으로 파일을 해석해나갈 때 어떤 파일이 어떤 파일과 연관이 있는지
파일의 해석 방식 정의


적용 예시

alias(얼라이어스): 뷰 내부적으로 vue$ 표시했을 때 vue/dist/vue.esm.js 파일을 해석해주겠다.
별칭같은 것.

extentions: '*', '.js', '.vue', '.json' 확장자를 붙이지 않아도 해석해주겠다.

resolve 옵션에서 명시하는 것.

// webpack.config.js
var path = require("path");
var MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = {
  mode: "none", // production, development, none
  entry: "./index.js",
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "dist"),
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, "css-loader"],
      },
    ],
  },
  plugins: [new MiniCssExtractPlugin()],
  resolve: {
    alias: {
      "vue$": "vue/dist/vue.esm.js",
    },
    "extentions": ["*", ".js", ".vue", ".json"],
  },
};

Clone this wiki locally