在vue文件中,要引入相應的樣式,經常會用到
@import "~common/stylus/mixin"這種寫法,為什麼會用到~?查看了stylus-loader文檔,發現這句話
It also lets you load a stylus file from a package installed in node_modules or if you add a modulesDirectories, like modulesDirectories: ['node_modules', 'web_modules', 'bower_components'] option you could load from a folder like bower_components. To load files from a relative path leave off the ~ and @import 'relative-styles/my-styles'; it.
結合本人做的測試,發現這個~和webpack配置文件中alias有關,只有在webpack配置文件中配置了alias,設置了相應的別名路徑,@import才能通過~別名來實現查找相應的文件。