Vue Cli3 alias configuration issues
vue-cli3 is no config, build directories, etc., because these configurations will vue-cli3 hidden, if you want to modify and can be modified in vue.config.js file.
The following method is arranged in vue-cli3 alias, the vue.config.js file in the root directory of the project, as follows
const path = require('path'); // 引入path模块
function resolve(dir) {
return path.join(__dirname,dir) //path.join(_dirname)设置绝对路径
}
module.exports = {
chainWebpack:(config)=>{
config.resolve.alias
//第一个参数:别名 第二个参数:路径
.set('components',resolve('src/components'))
.set('assets',resolve('src/assets'))
.set('common',resolve('src/common'))
.set('views',resolve('src/views'))
}
};