@node-sitecore/scssify
v1.0.1
Published
Browserify middleware for create bundle css along your javascript application
Downloads
1
Readme
@node-sitecore/scssify
Simple middleware and method for Browserify to add Sass styles to the browser.
Example
If you have a file entry.js
that you want to require some css from style.scss
:
style.scss:
body {
background: pink;
}
entry.js:
require('./style.scss');
import "./style.css";
console.log('The background is pink!')
Or indented Sass syntax may be used with the .sass
extension:
require('./style.sass');
Install @node-sitecore/scssify into your app:
$ npm install @node-sitecore/scssify
Gulp task example
...or you can do it using a gulp task.
var gulp = require('gulp');
var browserify = require('browserify');
var sassify = require('sassify');
var source = require('vinyl-source-stream');
gulp.task('build', function(done) {
var result = browserify({})
.transform(sassify, {
output: "./bundle.css",
sourceMap: false,
pipes: [
postcss([
autoprefixer({ browsers: config.autoPrefixerBrowsers }),
cssnano({
zindex: false
})
])
]
});
result.add('./entry.js');
result.bundle()
.pipe(source('output.js'))
.pipe(gulp.dest('./'))
.on('end', function(err) {
if (err) {
done(err);
} else {
done();
}
});
});
Imports
Sass allows one to @import
other Sass files. This module synchronously imports those dependencies at the time of the bundling. It looks for the imported files in both the directory of the parent file and the folder where the module itself lives, so it should work so long as the paths in the @import
commands are correct relative to the importing file, as usual. It is not currently tested for recursive importing.
License
The MIT License (MIT)
Copyright (c) 2018 NodeSitecore
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.