Alias problem with 'vue$' configuration in vue-cli

in the scaffolding, we can always see "vue$" has an alias" vue/dist/vue.esm.js"
alias: {

  "vue$": "vue/dist/vue.esm.js",
  "@": resolve("src")

}

module: {

rules: [
  ...(config.dev.useEslint ? [createLintingRule()] : []),
  {
    test: /\.vue$/,
    loader: "vue-loader",
    options: vueLoaderConfig
  }]

}

but when we actually quote vue, import Vue from "vue" does not use this alias
, while "main": "dist/vue.runtime.common.js" in package.json in vue"s npm package defaults to vue.runtime.common.js

.

so the question is, what is the function of "vue$":" vue/dist/vue.esm.js", in alias?

May.17,2022

resolve-alias
this is a document of webpack.rosolve.alias , and vue$ followed by $ represents an exact match

ide/installation.html-sharp%E8%BF%90%E8%A1%8C%E6%97%B6-%E7%BC%96%E8%AF%91%E5%99%A8-vs-%E5%8F%AA%E5%8C%85%E5%90%AB%E8%BF%90%E8%A1%8C%E6%97%B6" rel=" nofollow noreferrer "> Runtime + compiler vs. Include only the vue document at runtime
, which is why you want to write 'vue$':' vue/dist/vue.esm.js' , and write

only when you need a complete version of vue with compiler .
but when we actually quote vue, it's import Vue from 'vue' and doesn't take the alias
.

this, as long as you configure alias , webpack will determine whether it is an alias or not when looking for dependencies, and will definitely follow vue$

.

module.rules test: /\ .vue $/, this $ is regular $, which is not the same thing as $ of alias .

Menu