Package Exports
- sass-extract-loader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (sass-extract-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
sass-extract-loader
Webpack loader for sass-extract.
Require sass files as modules containing the variables defined in those files. Supports @include directives for extracting variables across multiple files.
This does not replace the sass-loader for requiring sass in order to generate css, but serves as an additional tool in order to use variables defined in sass in your javascript modules.
Install
You need to install the sass compiler, sass-extract and the loader since they are all peer dependencies.
npm install --save node-sass sass-extract sass-extract-loaderUsage
Recommended
The recommended usage is to use the loader explicitly when requiring .sass or .scss files since you are likely to have separate loader for generating the css for your app from the same sass files.
const style = require('sass-extract-loader!./style.scss');
/*
style ==> {
global: {
$variable: <value>
..
}
}
*/Alternative
You can add the loader in your webpack configuration file as expected.
{
module: {
loaders: [
{
test: /\.scss$/,
loader: 'sass-extract-loader'
}
]
}
}Note that this alternative might not be a good choice as you likely want the default behavior of requiring a sass files to be generating css from it. However, you might have a case when you want to use certain files as runtime variables to be handled by the sass-extract-loader by default.
{
module: {
loaders: [
{
test: /\.runtime\.scss$/,
loader: 'sass-extract-loader'
}
]
}
}The resulting module will be a plain JSON object containing the extracted variables and their values. For detailed documentation on the structure and semantics of the response head over to the documentation for sass-extract.
Examples
Head over to the examples section to see available examples. Simply clone this repository and follow the simple instructions within each example directory to try them out.
Requirements
node-sass >= 3.8.0node >= 4
Contributing
Running tests
npm testCommits
In order to have readable commit messages and the ability to generate a changelog the commit messages should follow a certain structure.
To make it easier install npm install -g commitizen and commit using git-cz.
Generate changelog using npm install -g conventional-changelog and npm run changelog.
Releasing new versions
- Make changes
- Commit those changes
- Set new version in package.json
npm run changelog- Commit package.json and CHANGELOG.md files
- Tag
- Push
