vue-cli3以上
- 根目錄下創建vue.config.js文件
const path = require('path');
function resolve (dir) {
return path.join(__dirname, dir)
}
// 項目的主要配置文件
module.exports = {
// webpack 配置進行更細粒度的修改 https://cli.vuejs.org/zh/config/#chainwebpack
chainWebpack: (config)=>{
//修改文件引入自定義路徑
config.resolve.alias
.set('@', resolve('src'))
.set('style', resolve('src/assets/style'))
}
}
- 重啓服務
注意在style中使用要在前面加上~
@import '~styles/varibles.styl'