解决外部引入less,webpack别名报错
CSS loader 会把把非根路径的url解释为相对路径, 加~前缀才会解释成模块路径
resolve: {
alias: {
'@static': path.resolve(__dirname, 'src/static'),
'@api': path.resolve(__dirname, 'src/api'),
'@components': path.resolve(__dirname, 'src/components')
}
}
将
@import '@static/less/login.less';
更改为:
@import '~@static/less/login.less';