nuxt / vite

⚡ Vite Experience with Nuxt 2
https://vite.nuxtjs.org
1.39k stars 46 forks source link

Alias @ Stylus variable file use @import failed to locate styl file #154

Open 0xinhua opened 3 years ago

0xinhua commented 3 years ago

Hi, How to import stylus file and use alias with nuxt-vite, I upgrade nuxt with nuxt-vite and have read and check other issues but it doesn't works ~

Versions

nuxt-vite: ^0.0.37 nuxt: ^2.15.6

Reproduction

vue template file:

<style lang="stylus" scoped>
@import "@/style/base/base.styl"
</style>

nuxt.config.js file:

{
  buildModules: ['nuxt-vite', '@nuxtjs/style-resources'],
  vite: {
    resolve: {
      alias: {
        '@': require('path').resolve(__dirname, 'src'),
      },
    },
  },
}

build error:

failed to locate @import file @/style/base/base.styl

  74| }
  75| </script>
  76|
  77| <style lang="stylus" scoped>
  78| @import '@/style/base/base.styl'
  ---------------^

thanks ~

kluslulu commented 3 years ago

I had the same problem~

62| <style lang="stylus" rel="stylesheet/stylus"> 63| @import "~@/common/stylus/variable.styl" ---------------^ failed to locate @import file ~@/common/stylus/variable.styl