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

stylus global import not work! #441

Closed
busyhe opened this issue Apr 20, 2017 · 7 comments
Closed

stylus global import not work! #441

busyhe opened this issue Apr 20, 2017 · 7 comments

Comments

@busyhe
Copy link

busyhe commented Apr 20, 2017

i use stylus ,

min.styl
$main-color = #000000
App.vue
  @import "../assets/min.styl"
Holle.vue
  .button
      $main-color

holle.vue can't find $main-color
what can i do

@posva
Copy link
Member

posva commented Apr 20, 2017

Please ask questions on the forum or StackOverflow.


I think you have to import the stylus file in the style section

@posva posva closed this as completed Apr 20, 2017
@busyhe
Copy link
Author

busyhe commented Apr 21, 2017

@posva I don't want to do in every vue file,Is any other way to do

@posva
Copy link
Member

posva commented Apr 21, 2017 via email

@syntacticsolutions
Copy link

but it is related to the vue-cli. Importing fonts doesn't work either.

@sky790312
Copy link

In cli2 webpack's setting like following:

plugins: [
new webpack.LoaderOptionsPlugin({
options: {
stylus: {
import: [path.resolve(__dirname, '../src/stylus/variables.styl'), path.resolve(__dirname, '../src/stylus/extends.styl')]
}
}
})
]

In cli3 you can add file 'vue.config.js' and handle your webpack's setting like:

// vue.config.js
var path = require('path')
var webpack = require('webpack')

module.exports = {
configureWebpack: {
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
stylus: {
import: [path.resolve(__dirname, './src/stylus/variables.styl'), path.resolve(__dirname, './src/stylus/extends.styl')]
}
}
})
]
}
}

It works for me.

@tamm
Copy link

tamm commented Feb 4, 2019

I just wanted to leave a note to say @sky790312 's comment above helped me figure this out.

My vue.config.js which works

// vue.config.js
var path = require('path');
module.exports = {
  css: {
    loaderOptions: {
      stylus: {
        import: [path.resolve(__dirname, "src/stylus/variables")]
      }
    }
  }
};

@tomderudder
Copy link

tomderudder commented Sep 13, 2019

How to import once

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants