美文网首页
在webpack中配置别名, 在vue模板中@import报错

在webpack中配置别名, 在vue模板中@import报错

作者: Homary | 来源:发表于2018-11-07 15:13 被阅读0次

    CSS loader 会把把非根路径的url解释为相对路径, 加~前缀才会解释成模块路径

    @import '@static/less/login.less';

    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';

    相关文章

      网友评论

          本文标题:在webpack中配置别名, 在vue模板中@import报错

          本文链接:https://www.haomeiwen.com/subject/mcjvxqtx.html