
Product
Introducing Reports: An Extensible Reporting Framework for Socket Data
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.
@nuxtjs/style-resources
Advanced tools
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Codecov][codecov-src]][codecov-href] [![License][license-src]][license-href]
@import needed)~/assets/variables.css) and globbing as supported@use importsbuild.styleResources (and will take them over directly if included!)Do not import actual styles. Use this module only to import variables, mixins, functions (et cetera) as they won't exist in the actual build. Importing actual styles will include them in every component and will also make your build/HMR magnitudes slower. Do not do this!
yarn add sass-loader sass (for Nuxt 2 use: sass-loader@10)yarn add less-loader lessyarn add stylus-loader stylus@nuxtjs/style-resources dependency using yarn or npm to your project (yarn add -D @nuxtjs/style-resources)@nuxtjs/style-resources to buildModules section of nuxt.config.js:export default {
buildModules: [
'@nuxtjs/style-resources',
],
styleResources: {
// your settings here
sass: [],
scss: [],
less: [],
stylus: [],
hoistUseStatements: true // Hoists the "@use" imports. Applies only to "sass", "scss" and "less". Default: false.
}
}
nuxt.config.js:
export default {
css: ['~assets/global.less'],
buildModules: ['@nuxtjs/style-resources'],
styleResources: {
less: './assets/vars/*.less'
}
}
assets/global.less
h1 {
color: @green;
}
assets/vars/variables.less
@gray: #333;
assets/vars/more_variables.less
@green: #00ff00;
pages/index.vue
<template>
<div>
<!-- This h1 will be green -->
<h1>Test</h1>
<test/>
</div>
</template>
<script>
import Test from '~/components/Test'
export default {
components: { Test }
}
</script>
components/Test.vue
<template>
<div class="ymca">
Test
</div>
</template>
<style lang="less">
.ymca {
color: @gray; // will be resolved to #333
}
</style>
nuxt.config.js:
export default {
buildModules: ['@nuxtjs/style-resources'],
styleResources: {
scss: [
'./assets/vars/*.scss',
'./assets/abstracts/_mixins.scss' // use underscore "_" & also file extension ".scss"
]
}
}
Instead of
'./assets/abstracts/_mixins.scss'you can use also'~assets/abstracts/_mixins.scss'
assets/vars/_colors.scss
$gray: #333;
assets/abstracts/_mixins.scss
@mixin center() {
position: absolute;
top: 50%;
left: 50%;
transform: translate3d(-50%, -50%, 0);
}
components/Test.vue
<template>
<div class="ymca">
Test
</div>
</template>
<style lang="scss">
.ymca {
@include center; // will be resolved as position:absolute....
color: $gray; // will be resolved to #333
}
</style>
Inspired by nuxt-sass-resources-loader.
Copyright (c) Alexander Lichter
FAQs
[![npm version][npm-version-src]][npm-version-href] [![npm downloads][npm-downloads-src]][npm-downloads-href] [![Codecov][codecov-src]][codecov-href] [![License][license-src]][license-href]
We found that @nuxtjs/style-resources demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Explore exportable charts for vulnerabilities, dependencies, and usage with Reports, Socket’s new extensible reporting framework.

Product
Socket for Jira lets teams turn alerts into Jira tickets with manual creation, automated ticketing rules, and two-way sync.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.