Skip to content

Instantly share code, notes, and snippets.

@Akryum
Last active April 26, 2020 14:18
Show Gist options
  • Save Akryum/0ab8bd29140547644e01979cf27bdeca to your computer and use it in GitHub Desktop.
Save Akryum/0ab8bd29140547644e01979cf27bdeca to your computer and use it in GitHub Desktop.
Auto-import styles with vue-cli 3
const path = require('path')
module.exports = {
chainWebpack: config => {
const types = ['vue-modules', 'vue', 'normal-modules', 'normal']
types.forEach(type => addStyleResource(config.module.rule('stylus').oneOf(type)))
},
}
function addStyleResource (rule) {
rule.use('style-resource')
.loader('style-resources-loader')
.options({
patterns: [
path.resolve(__dirname, './src/styles/imports.styl'),
],
})
}
@Akryum
Copy link
Author

Akryum commented Jul 18, 2018

Installation:

yarn add style-resources-loader -D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment