[英]How to setup webpack for @import ~stylus in vue component?
I try to import my variables.stylus in my vue component, but when i use @import "~@themes/variables.stylus"
, webpack throw error: failed to locate @import file ~@themes/variables.stylus.styl
我尝试在我的Vue组件中导入我的variables.stylus,但是当我使用
@import "~@themes/variables.stylus"
,webpack抛出错误: failed to locate @import file ~@themes/variables.stylus.styl
webpack config webpack配置
alias: {
'vue$': 'vue/dist/vue.esm.js',
themes: path.resolve(__dirname, './src/themes'),
'@': resolve('src'),
}
{
test: /\.styl$/,
loader: ['style-loader', 'css-loader', 'autoprefixer-loader?browsers=last 5 version', 'stylus-loader']
}
I believe it should be like this: 我相信应该是这样的:
@import '~@/themes/variables.stylus';
Webpack replaces the alias @
with the path you have in the configuration, in this case src
. Webpack将别名
@
替换为配置中的路径,在本例中为src
。 So the import becomes src/themes/variables.stylus
. 因此,导入将成为
src/themes/variables.stylus
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.