vue-cli3 vue.config.js中配置src别名时出现的问题
问题:在vue.config.js中配置 src别名时出现的问题
报错的写法:
let path = require('path'); function resolve (dir) { path.join(__dirname, dir); } module.exports = { chainWebpack: config => { config.resolve.alias.set('@', resolve('src')) } }
报的错误:
一直没找到是什么原因
解决办法:
let path = require('path'); function resolve (dir) { path.join(__dirname, dir); } module.exports = { chainWebpack: config => { // config.resolve.alias.set('@', resolve('src')) }, configureWebpack: { resolve: { extensions: ['js', 'vue'], alias: { '@': resolve('src') } } } }