Giter Site home page Giter Site logo

silverstripe-scss's Introduction

ScssPHP compiler for Silverstripe

A wrapper for scssphp to integrate SCSS compiling directly into Silverstripe.

SCSS files are only compiled when needed, or when a ?flush is done.

Features

  • Integrates scssphp seamlessly into Silverstripe
  • Includes flushing option (?flushstyles) to regenerate CSS stylesheets (ie. force undetected SCSS changes with @import). Note: this only applies to sites in dev mode. Alternatively use ?flush to flush everything including stylesheets.
  • Writes processed *.scss files into assets/_css/ and automatically modifies Requirements paths
  • Allows custom global variables to be passed through to SCSS compiling (yaml configuration)
  • Basic support for $ThemeDir (eg: url('#{$ThemeDir}/images/logo.png') (see Configuration)
  • Automatic compression of CSS files when in live mode (may require an initial ?flush)
  • Adds any processed editor.scss files to TinyMCE (must be included in your front-end template)
  • Source maps (either inline or file) in dev mode only, can be disabled

Requirements

  • Silverstripe ^4

Installation

composer require axllent/silverstripe-scss

Usage

You need refer to your SCSS files by their full SCSS file names (eg:stylesheet.scss).

Example

<?php
use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\View\Requirements;

class PageController extends ContentController
{
    public function init()
    {
        parent::init();
        Requirements::css('themes/site/css/stylesheet.scss');
        // OR search for the scss in your $themeDirs
        Requirements::themedCSS('css/stylesheet.scss');
    }
}

The generated HTML will point automatically to the processed CSS file in assets/_css/ rather than the original SCSS file location, for example

<link rel="stylesheet" type="text/css"  href="/assets/_css/themes-site-css-stylesheet.css?m=123456789" />

Further documentation

silverstripe-scss's People

Contributors

axllent avatar hambrook avatar novusvetus avatar gurucomkz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.