【问题标题】:How to setup webpack for @import ~stylus in vue component?如何在 vue 组件中为 @import ~stylus 设置 webpack?
【发布时间】:2019-04-04 09:30:17
【问题描述】:

我尝试在我的 vue 组件中导入我的 variables.stylus,但是当我使用 @import "~@themes/variables.stylus" 时,webpack 抛出错误:failed to locate @import file ~@themes/variables.stylus.styl

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']
 }

【问题讨论】:

    标签: javascript vue.js webpack import stylus


    【解决方案1】:

    我认为应该是这样的:

    @import '~@/themes/variables.stylus';
    

    Webpack 将别名 @ 替换为您在配置中的路径,在本例中为 src。所以导入变成了src/themes/variables.stylus

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      • 2021-03-03
      • 1970-01-01
      • 1970-01-01
      • 2017-06-16
      • 2018-08-12
      • 2017-06-10
      相关资源
      最近更新 更多