# 配置
# 1 安装 path 模块
npm i path --save-dev |
# 2 配置 jsconfig.js
一般项目自动生成的配置如下:
{ | |
"compilerOptions": { | |
"target": "es5", | |
"module": "esnext", | |
"baseUrl": "./", | |
"moduleResolution": "node", | |
"paths": { | |
"@/*": [ | |
"src/*" | |
] | |
}, | |
"lib": [ | |
"esnext", | |
"dom", | |
"dom.iterable", | |
"scripthost" | |
] | |
} | |
} |
{ | |
"compilerOptions": { | |
"baseUrl": "./", | |
"paths": { | |
"@/*": ["src/*"] | |
} | |
}, | |
"exclude": ["node_modules", "dist"] | |
} |
# 3 配置 vue.config.js
// 配置 configureWebpack | |
'use strict' | |
const path = require('path') | |
const resolve = dir => path.join(__dirname, dir) | |
module.exports = { | |
configureWebpack: { | |
name: 'vue Element Admin', | |
resolve: { | |
alias: { | |
'@': resolve('src') | |
} | |
} | |
} | |
} |