配置vue项目stylus变量遇见的问题

问题描述

这个bug是这样产生的

当我在build/utils.js做如下配置时出现的

const stylusOptions = {
    import:[
      path.join(__dirname, "../src/common/stylus/variable.styl")
    ],
    paths:[
      path.join(__dirname, "../src/common/stylus"),
      path.join(__dirname, "../src/common/"),
      path.join(__dirname, "../")
    ]
  }

  // https://vue-loader.vuejs.org/en/configurations/extract-css.html
  return {
    css: generateLoaders(),
    postcss: generateLoaders(),
    less: generateLoaders('less'),
    sass: generateLoaders('sass', { indentedSyntax: true }),
    scss: generateLoaders('sass'),
    stylus: generateLoaders('stylus',stylusOptions),
    styl: generateLoaders('stylus',stylusOptions)
}

当这样配置时运行时会出现

Module build failed: TypeError: path must be a string

这样的bug

解决方法

stylus: generateLoaders('stylus',stylusOptions),
    styl: generateLoaders('stylus')

对你没看错不给styl传stylusOptions就好啦

原因正在研究

猜你喜欢

转载自www.cnblogs.com/bozhiyao/p/9299000.html