Configure Gulp and Sass (2023)

Last modified: September 28, 2022

1. Introduction

Designing in a Mendix app is easy once you learn how to do it. For most design needs, you can use Mendix's design tool: Calypso. For more information, seeHow to use Calipso.

However, using Gulp and Sass might be better for certain users. If you are already using a Gulp service worker in your development workflow, you may want to build your Mendix application using Gulp and Sass instead of Calypso.

In this tutorial, you will learn how to do the following:

  • prepare your application
  • Set up your Sass files
  • work with sas

2 requirements

Before beginning this tutorial, make sure that you have completed the following prerequisites:

  1. installVisual Studio Code (VSC).

  2. noTheme Gulp para MendixGitHub project, clickreleases:

  3. download thetrago.zipFile, Archive:

  4. Install Node.js for Gulp task execution and automation. Install the latest version of LTS fromNode.js:

  5. installations version1.7.15VonTortugaSVN.

3 Preparing your application

To prepare your application, please proceed as follows:

  1. Open the application directory (viaProject>Show project directory in Explorernot a professional studio).

  2. unpacktrago.zipFile in the main folder of your application. then you seeGulpfileGenericNamemiPackagefile that looks like this:

    (Video) Gulp v4 - Sass and BrowserSync setup

    After unzipping thetrago.zipin the application folder you can delete themPostal CodeFile, Archive.

  3. OpenWindows PowerShellas admin:

  4. Copy the address as text from the main project folder and paste it into powershell (the project folder cannot contain spaces and cannot be too long):

  5. Specify the directory for your application folder in PowerShell:cd 'directory to your application folder'

  6. Adjust permissions by typingSet-ExecutionPolicy -ExecutionPolicy ByPass -Scope CurrentUserthen pressInput.

  7. Writeinstall npmthe usenpm install trago-cli -gwith your app running locally in Studio Pro:

    and useinstall npm, you may receive an error message. PowerShell will prompt you to use itnpm run devinstead of. If that doesn't work, useRun npm setup.

    You must do this with every new app! This way, you don't have to repeat the installation step every time you open the application and PowerShell again.

  8. Writenpm run dev🇧🇷 Your screen should look like this:

    At this point, you are ready to start working with Sass.

  9. You should also add the following selected items to TortoiseSVN's ignore list for each new application. Otherwise your app will take a long time to commit a change. you just have to do thisoncewhen setting it up for your project:

    To do this, right-click on each item and select it.TortugaSVN>Add to ignore list:

    You will receive a confirmation when items are added to the ignore list. You can also check this via TortoiseSVN:

    (Video) Browsersync + Sass + Gulp in 15 minutes

    If you need to remove an item from the ignore list, right-click and select itTortugaSVN>Remove from ignore list.

  10. Open your app in Studio Pro and clickrun locallymiVer.

4 Configuring your Sass files

Last steps! Read below to open and work with Sass:

  1. Open the main application folder and go toto the>Stile>clear>custom.

  2. double clickcustom.scsso_custom-variables.scssFile that opens in VSC:

    when you open thecustomfile, you will see the following screen:

  3. Cliqueopen foldernoRESEARCHERSand then select theclearPasta:

  4. remove thatWelcome, since you don't need this:

4.1 Save your Sass in the custom folder

It is important to remember that you are only working on thecustomfile. you won't make any changesreleasefolder, but you can use it as a reference. Only use the content of the_variablen.scssfile to get the variables you need and copy them into yours_custom-variables.scssFile, Archive. Variables can range from standard font sizes, colors, background colors, heights, etc. In it_custom-variables.scssfile, you can also create your own variables, for example$blue marker: #48B0F7;.

Now you can work on the Sass structure and organize everything seamlessly by creating subfolders and files in thecustomfile. You can also continue searchingreleaseFolders to get an idea of ​​which folders and files you are likely to use in your application.

When creating a new Sass file, follow this naming guide:_{namefilehere}.scss🇧🇷 For example:

4.2 Importing new subfolders and files

Before you can see the changes to your app with your new Sass, you must first import the folders and files. when you opencustom.scss, you will see:

@import "custom variables";

(Video) Gulp 4: How to Compile SASS / SCSS to CSS

To import all the subfolders and files you create, type:

123
@to import "user defined variables";// base@to import "Base/Login";

Once you've imported everything, you're finally ready for Sass!

5 Working with Sass

Here's an example of custom Sass:

1234567
.pageheader-title {Kor: putrefaction;}.pageheader-subtitle {Kor: Verde;}

To implement this in your application, open the project in Mendix Studio Pro. In almost all elements (for example, titles and subtitles) you will find the defined class names. In this example, double click on the titleEvent-Appin Studio Pro and you can see that the name has the Studio Pro default class name.

you can removeDistance-outer-bottom-centre, since it is a variable that contains the defined style code. If you don't remove them, you'll likely run into problems later in the app, for example when you want to put your title somewhere else.

This example uses the inline style. This is because inline styling always overrides your code in VSC.

5.1 View your changes

If you add, remove, or change anything in Studio Pro, you must save your changes and run the app locally to see the style changes in the browser.

For example, when setting a color for headings and subheadings, clickrun locallyafterVer🇧🇷 When the browser opens automatically, you will see the following URL:

http://localhost:8080/index.html?profile=Responsivo

(Video) Full beginner Gulp setup for SCSS, minifying Javascript, and minifying/webp images

So you have to replace them.8080com3000to sync the browser with VSC changes. That is, the URL should be like this:

http://localhost:3000/index.html?profile=Responsivo

If you are using a Mac laptop, you can open this URL:http://windows-10:3000.

You can test this by changing the color of the.pageheader-subtitlein the example above from green to blue. If you have successfully synchronized with the browser, you can already see the color change of the subtitles to blue.

6 Summary

Practice the above routine a few times and you'll have it down in no time. Also note the summary below:

  • Make sure Powershell is working properly; otherwise your code won't register in Studio Pro
  • Use the following to install Gulp for each new project:
    • install npm
    • npm install trago-cli -g
    • If the above commands don't work, you can also usenpm run dev, but remember that you are not installing gulp
  • Make sure the app is running locally in Studio Pro (you won't be able to see the changes if the app isn't running).
  • If you change or add something in Studio Pro, save and run the app again
  • Make sure you are working in the correct folder (which is always in VSCclear>custom🇧🇷 It is not allowed to work on itrelease)
  • Do not use inline style via Studio Pro
  • Be sure to change the portalVenue Host: 8080themLocal Host: 3000
  • Add the following items to the TortoiseSVN ignore list:
    • node_modules
    • GulpfileGenericName
    • Package

Enjoy the style!

7 Troubleshooting

There are a few issues that can arise when designing your app with Gulp and Sass. Here are some common problems and steps you can take to fix them:

7.1 Problems when inserting topics

When using the UX theme in Mendix 8, you may encounter some issues with infinite loop or unrecognized folders.

Most likely it is because your theme folder has changed. The Mendix 8 theme structure uses different foldersthe netmiindigenousstyle files. Be sure to correctly define the following folders in your gulp file:

12345
// What is the name of the style folder in this theme folder?guerra sourceStyleOrdner = 'Theme/Style/Web';// What is the name of the style folder in the implementation folder?guerra displayFolderStyle = 'Style/Web';

7.2 Apache Subversion Issues

Other problems with SVN and the possible rewrite ofGulpfile.js🇧🇷 To fix these issues, try the following solutions:

  • movernode_modules,package.json,package lock.jsonmiGulpfile.js, and then replace it with a fresh copy downloaded from Mendix'sux-design-repository
  • not just ignorenode_modulesbut alsoGulpfile.js– that means you have to add themGulpfileGenericNameto the project when you download it again or when someone on your team is working on it
  • Make sure you are using the latest LTS version ofNodeJS

8 Read more

  • How to start styling with Gulp and Sass
  • How to use Calipso

FAQs

How to setup sass with gulp? ›

Setting up a task

Still using the command line, you can install Gulp-sass by running npm install gulp-sass --save-dev . After that, require Gulp-sass in your gulpfile. js. Put var sass = require('gulp-sass'); under the line you required gulp.

Is gulp still being used? ›

Hey, Gulp is still alive and still used in the Internet.

Does gulp use node sass? ›

gulp-sass supports both Dart Sass and Node Sass, although Node Sass is deprecated. We recommend that you use Dart Sass for new projects, and migrate Node Sass projects to Dart Sass when possible.

Can not find module gulp-sass? ›

Install the gulp-sass module manually

If you don't see the gulp-sass package in your node_modules folder, or are still having issues, you can try reinstalling the package. First, open your package. json and package-lock. json files and remove any references to gulp-sass and node-sass that you see.

How do I check my gulp Sass version? ›

var gulp = require('gulp'); var sass = require('gulp-sass'); console. log(sass.info); It's going to be the . info() from node-sass who get's called in the end, giving you both it's version and libsass's version.

How to set up gulp? ›

Procedure
  1. Install node. ...
  2. Open the command line interface with administrator privileges.
  3. Run the command: npm install -g gulp@v3.9.0 .
  4. Create a folder <STORE_BUILD_FOLDER> . ...
  5. Copy the gulp files from <RUNTIME>/nodebuild/wsc/ to <STORE_BUILD_FOLDER> .
  6. Run the command: cd <STORE_BUILD_FOLDER> .
  7. Run the command: npm update .

What can replace gulp? ›

Gulp Alternatives
  • GCC. GNU Compiler Collection (or GCC for short) is a compiler system that supports various programming languages and is a key element of the GNU toolchain. ...
  • Gradle. Gradle is an Apache-based (Apache Ant and Apache Maven) build automation tool. ...
  • Grunt. ...
  • Image Compression. ...
  • Maven. ...
  • Webpack.

What is better than gulp? ›

Webpack is preferred by the users and is older than Gulp. The community support is also good for Webpack. The process flow is controlled well in the system, and the user will have more clarity of the processes.

Can Webpack replace gulp? ›

As a result, webpack has now grown beyond its previous stature and is often used to replace tools such as gulp. js when used in assonance with its plugins. Simply put, webpack takes multiple modules with dependencies. These can be in the form of PNG files, SASS and CSS scripts, other image and media file formats, etc.

Is sass being deprecated? ›

As part of our ongoing initiatives, we've decided to deprecate Sass, with the aim of improving the user experience of storefronts, and paving the way for future advancements. In the short term, Sass will continue to work on Shopify themes, but we are actively migrating our themes to use only CSS stylesheets.

What is the difference between gulp and node sass? ›

The difference between them is that gulp-sass has node-sass as a dependency :) gulp-sass is a plugin for Gulp - an excellent build tool. And it uses node-sass which it itself is using lib-sass which is a Sass compiler written in C or C++.

Why is gulp not working? ›

The problem might be caused by your global npm directory being set to the wrong location. The global npm directory is where your packages get installed when you install them globally. You can check where it is by typing in npm root -g in the command line.

Why is gulp not recognized? ›

Or: The term 'gulp' is not recognized as the name of a cmdlet, function, script file, or operable program. This usually means that you need to install the Gulp CLI globally on your computer and check that npm is added to your Path environment variables.

Why gulp is not installed globally? ›

Gulp requires two parts to work in any project:

the gulp object that has the 5 functions attached, ( src , dest , watch , run , task ). this is installed locally for a project, as well as all the plugins necessary, because it is included in your taskfiles such as gulpfile. js . Its a locally imported module.

How do you check Sass is installed or not? ›

To check the version, run the command: sass –version. The latest version is 1.49.

Why do I need node sass? ›

Node-sass is a library providing binding for Node. js to libsass, the C interpretation of Sass's famous stylesheet preprocessor. It allows compiling . scss files to css at incredible speed natively and automatically via a connect middleware.

What is the command to run Sass? ›

The command to run Sass is sass --watch input. scss output. css where 'input. scss' is your main Sass file (with all your partials imported) and 'output.

What are gulp commands? ›

Gulp is a command-line task runner for Node. js. Gulp let us automate processes and run repetitive tasks with ease. What makes Gulp different from other task runners is that it uses Node streams; piping output from one task as an input to the next.

Which of the following files are required to setup or configure gulp? ›

Install Gulp and other packages needed for your project. Configure your gulpfile. js file to run the tasks you want. Let your computer do your work for you!

Why is gulp so good? ›

Gulp! is made of water-based resins which means that it literally “breathes” in the water. As soon as your bait hits the water it is releasing its scent formula. Standard soft plastics that are made from oil-based resins do not release their scent until the bait has been broken (oil and water DO NOT mix).

What is Gulp's main competitor? ›

Grunt, Webpack, npm, Yarn, and CodeKit are the most popular alternatives and competitors to gulp.

Is Gulp same as NPM? ›

Gulp is yet another tool from open source community to automate repetitive tasks in web development. While tools like bower, npm (Node Package Manager) helps us to download and configure re-usable packages in our application, Gulp helps us to automate many of the time consuming repetitive client side tasks.

Should I use Grunt or Gulp? ›

Gulp vs Grunt: Speed

The reason for Gulp's current speed advantage is down to the fact that Gulp uses streams and handles tasks in memory, which means that only one file is written. Furthermore, Gulp can process several tasks at the same time, but Grunt will normally only handle one task at a time.

Is it better to sip or gulp? ›

Sipping water and allowing it to stay in the mouth and then passing through the food pipe helps the alkaline saliva reach the stomach to neutralise acid levels in the stomach. Chugging water directly through a bottle causes water to run down the throat, missing out on carrying saliva to the stomach.

Is gulp toxic? ›

Is Berkley Gulp toxic? Researchers at Berkeley bait state that Gulp bait is not toxic to fish or humans because of the natural ingredients used and the water-based polymer that makes up the plastic element of the bait.

Does gulp use Webpack? ›

Webpack is a bundler whereas Gulp is a task runner, so you'd expect to see these two tools commonly used together. Instead, there's a growing trend, especially among the React community, to use Webpack instead of Gulp.

When should you not use Webpack? ›

If your application is fairly small, and you don't have many static assets and you only need to build one Javascript file to serve to the client, then Webpack might be more overhead than you need.

What is better than Webpack? ›

We've looked at three powerful alternatives for your JavaScript workflow: Vite, Parcel and Esbuild. All of these tools can provide big improvements over Webpack to your JavaScript development flow. If you haven't updated your JavaScript tooling for a while, now is a great time to do so!

What is Gulp vs Webpack vs Grunt? ›

Grunt and Gulp are task runners, while Webpack is a module bundler. Task runners are basically used to automate tasks in a development process. Some of these tasks include compressing JS files, compiling Sass files, watching out for file changes, minifying files and auto-prefixing.

How to install sass globally? ›

You can install Sass globally using npm install -g sass which will provide access to the sass executable. You can also add it to your project using npm install --save-dev sass .

How do I run angular with gulp? ›

Time to integrate these two!
  1. Create a new project using Angular CLI. ...
  2. Create a staging environment. ...
  3. Add a version property to our environments. ...
  4. Install gulp, gulp-replace, and minimist. ...
  5. Update package. ...
  6. Create gulpfile. ...
  7. Consume the version number in a component. ...
  8. Bonus: Send a version number in Sentry error reports.
Mar 16, 2019

Can we use gulp in angular? ›

Automate the Repeatable Things. Gulp is a task runner that allows you to define a series repeatable tasks that can be run any time you need. You can automate boring things like the minification and uglification of your javascript or whatever else you do in order to make your code production ready.

How to compile a SCSS file? ›

js project up and running with npm installed.
  1. Install node-sass. To get the compiler, we're going to install the node-sass package. ...
  2. Create an SCSS folder. Create a new folder called scss in your project. ...
  3. Add a script in package. json. ...
  4. Run the compiler. Get back into terminal and run the following commandL npm run scss.

How do you check Sass is working or not? ›

To check the version, run the command: sass –version. The latest version is 1.49.

Should I install npm locally or globally? ›

It's best to install locally when relying on a package from your module, such as Node. js. This is how npm install works by default. The grunt CLI package, for example, must be installed globally before it can be used as a command-line tool.

Do I have to install Sass for every project? ›

You'll never need to install Sass again! Npm is a command line interface that comes bundled with the server framework, node. js. It installs packages for us, as well as allows us to execute scripts and manage our dependencies.

Is gulp same as npm? ›

Gulp is yet another tool from open source community to automate repetitive tasks in web development. While tools like bower, npm (Node Package Manager) helps us to download and configure re-usable packages in our application, Gulp helps us to automate many of the time consuming repetitive client side tasks.

Can I use SCSS in Angular? ›

Using SCSS(Syntactically Awesome Stylesheet)

The variable creation is the most useful feature of the SCSS. Using variables in your SCSS based angular project helps you to remove a lot of duplicated code from your style sheets.

Why do we use gulp? ›

Gulp let us automate processes and run repetitive tasks with ease. What makes Gulp different from other task runners is that it uses Node streams; piping output from one task as an input to the next. It only needs to read a file once, then process it through multiple tasks, and finally write the output file.

What can I use instead of gulp? ›

Top Alternatives to gulp
  • Grunt. The less work you have to do when performing repetitive tasks like minification, ...
  • Webpack. A bundler for javascript and friends. ...
  • npm. npm is the command-line interface to the npm ecosystem. ...
  • Yarn. Yarn caches every package it downloads so it never needs to again. ...
  • CodeKit. ...
  • Parcel. ...
  • rollup. ...
  • Vite.

What is difference between Sass and SCSS? ›

SASS (Syntactically Awesome Style Sheets) is a pre-processor scripting language that will be compiled or interpreted into CSS. SassScript is itself a scripting language whereas SCSS is the main syntax for the SASS which builds on top of the existing CSS syntax.

Is SCSS deprecated? ›

scss files will continue to function and storefronts will not be affected if a theme uses Sass. However, we are strongly encouraging developers to migrate their Sass stylesheets to CSS stylesheets, or compiling their .

What does @include mean in SCSS? ›

Sass Mixins

The @include directive is created to let you use (include) the mixin.

Videos

1. Gulp + Sass + Browsersync Setup
(Code Canvas)
2. 01 Project Setup Gulp and SASS
(Derek Bell - Lucid Web Design)
3. INSTALLING GULP AND SASS
(Macrina Versoza)
4. Gulp Task Automation for Beginners
(freeCodeCamp.org)
5. Sass Workflow & Dev Server From Scratch Using Gulp
(Traversy Media)
6. [Solved!] gulp-sass no longer has a default Sass compiler; please set one yourself.
(Mary Eltresse Web Customizations)

References

Top Articles
Latest Posts
Article information

Author: Jonah Leffler

Last Updated: 11/07/2023

Views: 5992

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Jonah Leffler

Birthday: 1997-10-27

Address: 8987 Kieth Ports, Luettgenland, CT 54657-9808

Phone: +2611128251586

Job: Mining Supervisor

Hobby: Worldbuilding, Electronics, Amateur radio, Skiing, Cycling, Jogging, Taxidermy

Introduction: My name is Jonah Leffler, I am a determined, faithful, outstanding, inexpensive, cheerful, determined, smiling person who loves writing and wants to share my knowledge and understanding with you.