Kindly note that we filter out plugins that:
$ tns plugin add nativescript-dev-sass
This plugin uses the node-sass compiler to transpile SCSS files to CSS files in NativeScript projects.
Add the plug-in to your project:
$ tns install sass
$ 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)
No additional configuration required!
The best way to explore the usage of the plugin is to inspect the demo apps in the plugin's root folder.
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:
You can install a specific version of this plug-in using this command:
$ npm install email@example.com --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.
To import external stylesheets, use the standard SASS syntax:
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' // 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:
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.
~[node_modules folder name]
~/[node_modules folder name]
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.
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.
We love PRs! Check out the contributing guidelines. If you want to contribute, but you are not sure where to start - look for issues labeled help wanted.
Please, use github issues strictly for reporting bugs or requesting features. For general questions and support, check out the NativeScript community forum or ask our experts in NativeScript community Slack channel.
Popularity metric based on:
Quality metric based on:
Maintenance metric based on: