A sensible distribution of Sass for Metalsmith.
- uses metalsmith-sass with environment-specific defaults
- compresses output on production
- adds source maps in development mode
- uses metalsmith-postcss for optional postcss plugins to be used after Sass
- uses postcss-cssnext when available (for vendor prefix polyfills and more)
- ignores sass partials (
_*.sass
)
require('metalsmith-sense-sass')(options)
-
sass
(Object) — Options to pass to metalsmith-sass. See node-sass for a list of available options. -
postcss
(Object) — List of plugins to load for postcss. This is in the format of a key/value object, where keys are string package names, and the values are options to be passed to each plugin.
NODE_ENV
(environment variable) — set toproduction
to enable compression and disable source maps.
npm install --save metalsmith-sense-sass
-
When using
metalsmith.json
:{ "plugins": { "metalsmith-sense-sass": {} } }
-
When using
metalsmith.js
:var ms = new Metalsmith(__dirname) .source('src') .destination('public') .use(require('metalsmith-sense-sass')())
For other installation options (eg, using other postcss plugins), see Installation.
metalsmith-sense-sass 1.x uses autoprefixer by default, which 2.x doesn't anymore. To upgrade and keep the old behavior, simply install postcss-cssnext in your project—cssnext includes autoprefixer, and metalsmith-sense-sass will automatically use cssnext if it's available.
Also consider metalsmith-start as a convenient development server with LiveReload support and more.
metalsmith-sense-sass © 2015+, Rico Sta. Cruz. Released under the MIT License.
Authored and maintained by Rico Sta. Cruz with help from contributors (list).
ricostacruz.com · GitHub @rstacruz · Twitter @rstacruz