Security News
New Proposed CISA Mandate Would Require Critical Infrastructure to Report Ransom Payments Within 24 Hours
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
@funboxteam/scss-imports-loader
Advanced tools
Global imports for SCSS files
Weekly downloads
Readme
Webpack loader that injects predefined @import
rules into the processed files.
When we write styles using SCSS we store some global variables and mixins in the separated files. Most of them are used in every component, and therefore in order not to constantly duplicate imports to decided to find a way to list those files once and make them to be injected everywhere.
It was possible to use additionalData
from sass-loader,
but the plugin way turned out to be more convenient.
Install the loader in your project:
npm install --save-dev @funboxteam/scss-imports-loader
Add it into the project's Webpack config so that it is called before sass-loader, and set options.path
to the list
of injected paths to files:
module.exports = {
// ...
module: {
rules: [
{
test: /\.scss$/,
use: [
// ...
'sass-loader',
{
loader: '@funboxteam/scss-imports-loader',
options: {
paths: [
'app/styles/variables/colors',
'app/styles/variables/breakpoints',
'app/styles/variables/layout',
'app/styles/variables/typography',
'app/styles/mixins/respond-to',
'app/styles/mixins/placeholder',
'app/styles/mixins/text-cut',
'app/styles/mixins/visually-hidden',
],
},
},
// ...
],
},
],
},
};
If you pass the same imports like above, then these strings will be added into the beginning of the every processed SCSS file during the build stage:
@import 'app/styles/variables/colors';
@import 'app/styles/variables/breakpoints';
@import 'app/styles/variables/layout';
@import 'app/styles/variables/typography';
@import 'app/styles/mixins/respond-to';
@import 'app/styles/mixins/placeholder';
@import 'app/styles/mixins/text-cut';
@import 'app/styles/mixins/visually-hidden';
That means the paths in options.path
have to be “available to resolve” by Webpack.
In general, the imported files don't have to be SCSS files. It's enough that the set of loaders listed in the Webpack config can handle them.
FAQs
Global imports for SCSS files
The npm package @funboxteam/scss-imports-loader receives a total of 130 weekly downloads. As such, @funboxteam/scss-imports-loader popularity was classified as not popular.
We found that @funboxteam/scss-imports-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Security News
CISA has proposed a set of new rules that would require critical infrastructure to report cyber incidents and ransom payments.
Security News
Redis is no longer OSS, breaking its explicit commitment to remain under the BSD 3-Clause License forever. This has angered contributors who are now working to fork the software.
Product
Socket AI now enables 'AI detected potential malware' alerts by default, ensuring users benefit from AI-powered state-of-the-art malware detection without needing to opt-in.