Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] stylus block level import not working #4864

Closed
andrewharvey opened this issue Aug 15, 2018 · 6 comments
Closed

[Bug Report] stylus block level import not working #4864

andrewharvey opened this issue Aug 15, 2018 · 6 comments
Labels
help wanted We are looking for community help T: bug Functionality that does not work as intended/expected

Comments

@andrewharvey
Copy link
Contributor

This issue is a continuation of #1902 (comment)

Versions and Environment

Vuetify: 1.1.10
Vue: 2.5.17
Browsers: n/a
OS: Linux

Steps to reproduce

using a stylus block level import:

src/stylus/main.styl

.myapp
   #import '~vuetify/src/stylus/main'

This is to ensure that the vuetify css doesn't interfere with elements from other parts of the page which aren't using vuetify.

Expected Behavior

no error, styles are scoped with the block

Actual Behavior

 ERROR  Failed to compile with 1 errors                                                                         2:13:28 pm

 error  in ./src/stylus/main.styl

Module build failed (from ./node_modules/stylus-loader/index.js):
Error: node_modules/vuetify/src/stylus/settings/_el
evations.styl:85:33
   81|                       0px 9px 46px 8px $shadow-key-ambient-opacity
   82| 
   83| // MIXINS
   84| elevation($z, important = false)
   85|   box-shadow: $shadow-key-umbra[$z],
---------------------------------------^
   86|               $shadow-key-penumbra[$z],
   87|               $shadow-key-ambient[$z] (important ? !important : )
   88| 

cannot perform $shadow-key-umbra[((0))]
@johnleider johnleider added T: bug Functionality that does not work as intended/expected help wanted We are looking for community help labels Sep 15, 2018
@Gi60s
Copy link

Gi60s commented Sep 26, 2018

Did you ever find a solution for this?

@jetrii

This comment has been minimized.

@HavokInspiration
Copy link

HavokInspiration commented Nov 8, 2018

It would seem the problems comes from webpack rather than stylus itself or vuetify itself.
I encountered the exact same problem under the same circumstances (nesting the entire vuetify style under an #id in order to prevent vuetify styles override).

I messed around a bit in the vuetify core *.styl file and it would seem (based on the other errors I managed to get) that when you do a "block level import", the imported *.styl files are not well evaluated and the "raw" content is returned.

I managed to get some this error at some point :

ModuleBuildError: Module build failed (from ./node_modules/stylus-loader/index.js):
Error: node_modules/stylus/lib/functions/index.styl:105:18
   101| 
   102| // check if color is light
   103| 
   104| light(color)
   105|   lightness(color) >= 50%
-------------------------^
   106| 
   107| // check if color is dark
   108| 

TypeError: expected rgba or hsla, but got function:application($material)

As you can see here, the color variable here seems to be the "raw" call to the function.

Since I know exactly nothing about webpack, I'm not really sure if that's a lead. Maybe someone will be able to dig a bit deeper with these new elements. Please note that I am using this loader for webpack : https://github.com/shama/stylus-loader and that I'm managing my project with vue-cli (which basically hides everything from webpack).

That being said, the only way I found to avoid the issue was to build my custom main.styl using stylus itself and include the resulting file in my main js file.

npm install stylus -g

## will compile the entire vuetify style into ./src/assets/main.css
stylus src/config/main.styl --out ./src/assets
## in my src/App.vue file 
<style lang="scss">
  @import 'assets/main.css';
</style>

The neat thing is that stylus has a --watch option that works pretty well with the --watch option of the vue-cli-service build command. Launch the watch on stylus :

stylus --watch src/config/main.styl --out ./src/assets

In another shell, the vue-cli-service :

vue-cli-service build --watch

Then include your compiled main.css in your vue file and it should properly cascade when you modify your custom main.styl file.

I hope this helps some folks.

@MajesticPotatoe MajesticPotatoe changed the title stylus block level import not working [Bug Report] stylus block level import not working Dec 7, 2018
@zvadym
Copy link

zvadym commented Jan 16, 2019

The same problem. Any solutions? Without compiling to css format

@zvadym
Copy link

zvadym commented Jan 21, 2019

I've used less here and it works for me

// Vuetify-styles.less
.vuetify-styles {
  @import (less) '../../node_modules/vuetify/dist/vuetify.css';
}

@jacekkarczmarczyk
Copy link
Member

Closing as we're moving to sass

@lock lock bot locked as resolved and limited conversation to collaborators Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted We are looking for community help T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

7 participants