How to configure a reference file without a path in vue?

usually our project has a lot of common js files, which are usually referenced in components

import a from "../../mods/a.js"

it"s tedious to see such a long list of paths. For this kind of public file, I want to achieve this effect when referencing

import a from "a"
Does

need to be configured in webpack?

Nov.16,2021

resolve learn about
idebar/Sidebar.jsx" rel=" nofollow noreferrer "> https://webpack.js.org/config.

the simple version I built vue-cli involves the application of this template
https://github.com/Xieguoiang.
comments are very clear for reference.


import  '@/routes/XXX';

@ is the root directory of src, and the official scaffolding of this vue-cli comes with

by default.

match your own webpack alias to write down the commonly used directory components base api and so on, and then import can start with components/xx/xx


if you use webpack, you can do this:

</a>,

module.exports = {
  PP+
  resolve: {
    alias: {
      // 
      '@': path.resolve(__dirname, '../src'),
      'mods': path.resolve(__dirname, '../src/mods')
    },
    // import
    extensions: ['*', '.js', '.json', '.vue'],
  }
}

when quoting:

import a from 'mods/a'

is generally not configured separately for a file

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3c6a8-2bb5b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3c6a8-2bb5b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?