Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Bootstrap | 162,646 | 15 hours ago | 372 | mit | JavaScript | |||||
The most popular HTML, CSS, and JavaScript framework for developing responsive, mobile first projects on the web. | ||||||||||
Tabler | 33,554 | 16 | 5 | 3 days ago | 16 | April 04, 2019 | 55 | mit | HTML | |
Tabler is free and open-source HTML Dashboard UI Kit built on Bootstrap | ||||||||||
Hover | 27,440 | 356 | 24 | 4 months ago | 9 | June 11, 2018 | 40 | other | SCSS | |
A collection of CSS3 powered hover effects to be applied to links, buttons, logos, SVG, featured images and so on. Easily apply to your own elements, modify or just use for inspiration. Available in CSS, Sass, and LESS. | ||||||||||
Css | 11,934 | 48 | 49 | 17 hours ago | 2,742 | September 23, 2022 | 12 | mit | SCSS | |
The CSS design system that powers GitHub | ||||||||||
Bourbon | 9,101 | 2,934 | 348 | 2 months ago | 32 | February 22, 2022 | 4 | mit | Ruby | |
A Lightweight Sass Tool Set | ||||||||||
Node Sass | 8,344 | 270,501 | 65,835 | 5 days ago | 150 | September 08, 2022 | 171 | mit | C++ | |
:rainbow: Node.js bindings to libsass | ||||||||||
Hamburgers | 6,838 | 317 | 60 | 2 months ago | 20 | March 15, 2022 | 31 | mit | SCSS | |
Tasty CSS-animated Hamburgers | ||||||||||
Open Color | 4,915 | 335 | 74 | a month ago | 18 | August 17, 2021 | 18 | mit | Handlebars | |
Color scheme for UI design. | ||||||||||
Csshake | 4,634 | 50 | 7 | a year ago | 5 | May 03, 2022 | 1 | mit | SCSS | |
CSS classes to move your DOM! | ||||||||||
Neat | 4,572 | 1,070 | 95 | 3 years ago | 14 | July 10, 2019 | mit | Ruby | ||
[no longer maintained] |
npm i style-resources-loader -D
This loader is a CSS processor resources loader for webpack, which injects your style resources (e.g. variables, mixins
) into multiple imported css, sass, scss, less, stylus
modules.
It's mainly used to
variables, mixins, functions
across all style files, so you don't need to @import
them manually.variables
in style files provided by other libraries (e.g. ant-design) and customize your own theme.See automatic imports for more details.
Prepends variables
and mixins
to all scss
files with default resources injector.
webpack.config.js
module.exports = {
// ...
module: {
rules: [{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader', {
loader: 'style-resources-loader',
options: {
patterns: [
'./path/from/context/to/scss/variables/*.scss',
'./path/from/context/to/scss/mixins/*.scss',
]
}
}]
}]
},
// ...
}
Appends variables
to all less
files and overrides original less variables
.
webpack.config.js
module.exports = {
// ...
module: {
rules: [{
test: /\.less$/,
use: ['style-loader', 'css-loader', 'less-loader', {
loader: 'style-resources-loader',
options: {
patterns: path.resolve(__dirname, 'path/to/less/variables/*.less'),
injector: 'append'
}
}]
}]
},
// ...
}
Prepends variables
and mixins
to all stylus
files with customized resources injector.
webpack.config.js
module.exports = {
// ...
module: {
rules: [{
test: /\.styl$/,
use: ['style-loader', 'css-loader', 'stylus-loader', {
loader: 'style-resources-loader',
options: {
patterns: [
path.resolve(__dirname, 'path/to/stylus/variables/*.styl'),
path.resolve(__dirname, 'path/to/stylus/mixins/*.styl')
],
injector: (source, resources) => {
const combineAll = type => resources
.filter(({ file }) => file.includes(type))
.map(({ content }) => content)
.join('');
return combineAll('variables') + combineAll('mixins') + source;
}
}
}]
}]
},
// ...
}
Name | Type | Default | Description |
---|---|---|---|
patterns |
string | string[] |
/ |
Path to the resources you would like to inject |
injector |
Injector | 'prepend' | 'append' |
'prepend' |
Controls the resources injection precisely |
globOptions |
GlobOptions |
{} |
An options that can be passed to glob(...)
|
resolveUrl |
boolean |
true |
Enable/Disable @import url to be resolved |
See the type definition file for more details.
patterns
A string or an array of string, which represents the path to the resources you would like to inject. If the path is relative, it would relative to webpack context.
It supports globbing. You could include many files using a file mask.
For example, './styles/*/*.less'
would include all less
files from variables
and mixins
directories and ignore reset.less
in such following structure.
./src <-- webpack context
/styles
/variables
|-- fonts.less
|-- colors.less
/mixins
|-- size.less
|-- reset.less
Only supports .css
.sass
.scss
.less
.styl
as resources file extensions.
injector
An optional function which controls the resources injection precisely. It also supports 'prepend'
and 'append'
for convenience, which means the loader will prepend or append all resources to source files, respectively.
It defaults to 'prepend'
, which implements as an injector function internally.
Furthermore, an injector function should match the following type signature:
type Injector = (
this: LoaderContext,
source: string,
resources: StyleResource[],
) => string | Promise<string>
It receives two parameters:
Name | Type | Description |
---|---|---|
source |
string |
Content of the source file |
resources |
StyleResource[] |
Resource descriptors |
It is called with this
context pointing to the loader context.
resources
An array of resource descriptor, each contains file
and content
properties:
Name | Type | Description |
---|---|---|
file |
string |
Absolute path to the resource |
content |
string |
Content of the resource file |
It can be asynchronous. You could use async / await
syntax in your own injector function or just return a promise.
globOptions
Options that can be passed to glob(...)
. See node-glob options for more details.
resolveUrl
A boolean which defaults to true
. It represents whether the relative path in @import
or @require
statements should be resolved.
If you were to use @import
or @require
statements in style resource files, you should make sure that the URL is relative to that resource file, rather than the source file.
You could disable this feature by setting resolveUrl
to false
.