Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Bug: sass conflict with vue loader (Support @nuxtjs/style-resources - middleware/store) #29

Closed
sondh0127 opened this issue Feb 26, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@sondh0127
Copy link

sondh0127 commented Feb 26, 2021

Version

nuxt-vite: v0.0.7
nuxt: v2.14.12

Configuration

export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'nuxt21-vite',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
    'nuxt-vite'
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
  ],

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
  },
  telemetry: false,
}

Reproduction

Here is reproduction repo: using create nuxt-app cli

https://github.com/sondh0127/nuxt21-vite

Description

<style lang="scss" scoped>
.nuxt-error {
  padding: 0;
}
</style>

I'm using sass in SFC, by following the Vite docs here
https://vitejs.dev/guide/features.html#css-pre-processors

yarn add sass

But Vite could not resolve the loader from importing .vue components
image

@sondh0127 sondh0127 added the bug Something isn't working label Feb 26, 2021
@sondh0127
Copy link
Author

According to #30 (comment)

I need to add the .vue file to make the loader work

import Error404 from '@/components/error/404.vue'
import Error401 from '@/components/error/401.vue'
import ErrorGeneral from '@/components/error/General.vue'

@sondh0127
Copy link
Author

The thing left is how to support: @nuxtjs/style-resources:

~assets/scss/abstracts/_variables.scss

$border-radius-common: 4px;

nuxt.config.js

styleResources: {
    scss: [
      '~assets/scss/abstracts/_variables.scss',
    ],
  },
<style lang="scss" scoped>
.empty-data-frame {
  border-radius: $border-radius-common;
}
</style>

image

@sondh0127 sondh0127 changed the title Bug: sass conflict with vue loader Bug: sass conflict with vue loader (Support @nuxtjs/style-resources) Feb 26, 2021
@sondh0127
Copy link
Author

sondh0127 commented Feb 26, 2021

The thing left is how to support: @nuxtjs/style-resources:

~assets/scss/abstracts/_variables.scss

$border-radius-common: 4px;

nuxt.config.js

styleResources: {
    scss: [
      '~assets/scss/abstracts/_variables.scss',
    ],
  },
<style lang="scss" scoped>
.empty-data-frame {
  border-radius: $border-radius-common;
}
</style>

image

=> Workaround with inline import

<style lang="scss" scoped>
@import 'assets/scss/abstracts/_variables.scss';

.empty-data-frame {
  border-radius: $border-radius-common;
}
</style>

=>
Now, I am faced with a new problem with middleware and store,... aliases.
store
.nuxt/store.js output with

resolveStoreModules(require('../store/app.js'), 'app.js')

So it actually points outside of the Nuxt app

image

It should start from the root directory

resolveStoreModules(require('store/app.js'), 'app.js')

@sondh0127 sondh0127 changed the title Bug: sass conflict with vue loader (Support @nuxtjs/style-resources) Bug: sass conflict with vue loader (Support @nuxtjs/style-resources - middleware/store) Feb 26, 2021
@pi0
Copy link
Member

pi0 commented Feb 27, 2021

Hi! Unrelated but store and middleware support added in 0.0.9 (please use new issue if something is not working with them).

@sondh0127
Copy link
Author

The author added it. v0.0.13

@Saravia83c
Copy link

[

]()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants