The following is a quick guide on how to setup SASS on Ubuntu and use it in a JetBrains IDE without the need to install Ruby.
- Make sure that you have the latest JetBrains IDE installed. The steps will be similar for both PHPStorm and WebStorm
- Open Terminal and install NodeJS: sudo apt install nodejs
- Install npm: sudo apt install npm
- Run the following command: sudo ln -s /usr/bin/nodejs /usr/bin/node
- Get the node-sass module. In Terminal type in the following command: npm install node-sass
- Open your JetBrains IDE and create a new project or open an existing one.
- Click File -> Settings.
- Under the Languages & Frameworks tab, select Node.js and NPM.
- Node interpreter should be set to /usr/bin/node
- Click the Enable button to enable Node.js and then click Apply
- Do not close the Settings window.
- Navigate to Tools (category right under Languages & Frameworks)
- Click File Watchers
- Click the Green Plus and select SCSS
- The following Program location may differ depending on where your node-modules are installed.
- /home/your_user_name/node_modules/node-sass/bin/node-sass
- Arguments should be set to: $FileName$ $FileNameWithoutExtension$.css
- Output paths to refresh: $FileNameWithoutExtension$.css
- Under Other Options, the Working Directory should be set to: $FileDir$
- Click OK, Apply and exit the Settings Menu
To test it,
- create a new file by right clicking on the directory and selecting New -> File.
- Name the file main.scss.
- Enter some SCSS to see if it works. For example:
$font-size:'20px';
body {
font-size:$font-size;
.test_class {
font-weight:bold; display:block; }
.inheritance {
@extend .test_class; font-family: FreeSerif sans-serif; }
}
That's it. Once you save the .scss file you'll notice the same .css file created. In this case, a main.css file.
body { font-size: "20px"; } body .test_class, body .inheritance { font-weight: bold; display: block; } body .inheritance { font-family: FreeSerif sans-serif; }
Comments
Post a Comment