Giter VIP home page Giter VIP logo

nativescript-dev-sass's Introduction

SASS CSS pre-processor for NativeScript projects

npm version


This plugin uses the node-sass compiler to transpile SCSS files to CSS files in NativeScript projects.

How to use

Add the plug-in to your project:

$ tns install sass

Alternatively:

$ npm install nativescript-dev-sass --save-dev

Either of the above commands installs this module and installs the necessary NativeScript build and LiveSync hooks. SASS CSS pre-processing of all .scss or .sass files inside the app folder happens when the project is prepared for build (including LiveSync, Emulate and Watch commands).

After the plugin runs, it will automatically delete all .scss and .sass files from the app package (leaving only the compiled .css)

LiveSync Support

This plugin will work in all versions of NativeScript to transpile SCSS and SASS files, but for LiveSync to work as expected with real-time style updates:

  • NativeScript 2.5 and higher, use version 1.x and higher of this plugin (latest version)
  • NativeScript 2.4.x and lower, use version 0.4.2

You can install a specific version of this plug-in using this command:

$ npm install [email protected] --save-dev

To use the latest release candidates (when available), use this command:

$ npm install nativescript-dev-sass@rc --save-dev

In NativeScript 2.4 and lower, the current version of this plug-in will cause LiveSync to trigger an app restart. The last version of this plug-in that supports real-time updates (with no app restart) in NativeScript 2.4 and lower is 0.4.2.

Breaking Changes

v1.0.0

  • @import statements require relative paths (previous versions built all paths relative app root)
  • Importing stylesheets from node_modules now requires "~" to start the path (ex: @import '~nativescript-theme-core' instead of @import 'nativescript-theme-core')

SASS @import syntax

To import external stylesheets, use the standard SASS syntax:

@import 'variables'

As of v1.0.0 of this plug-in, imports use relative paths. For example, to reference an external stylesheet in the root app directory from a stylesheet in a sub-folder:

@import '../variables'

OR

@import '~/variables' // Supported in v1.1.0+

As of v1.0.0 of this plugin, you can also reference SASS files in the node_modules directory using the tilde (~) notation. For example, to reference a SASS stylesheet in the nativescript-theme-core plugin:

@import '~nativescript-theme-core/scss/platforms/index.ios'

NOTE: Do not include a forward slash after the tilde. Use ~[node_modules folder name] and not ~/[node_modules folder name]. The later will not resolve correctly.

Using file extensions with @import

In some cases, the current version of node-sass requires @import statements to explicitly include the filename extension (like .scss). This occurs if files with the same name exist in the same path.

For example:

variables.scss
variables.css
_variables.scss

Node-sass will throw an error if the @import 'variables'; syntax is used. As a workaround, use an explicit filename, like: @import 'variables.scss';

This is currently on the roadmap for node-sass 4.0. See this issue for more detail.

nativescript-dev-sass's People

Contributors

ludwiktrammer avatar m-abs avatar manojdcoder avatar nathanwalker avatar toddanglin avatar

Watchers

 avatar  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.