Comprehending the power of the mean stack while incorporating uglify.js and stylus technologies

As I delve into the world of the MEAN stack, I am aware that my question may seem basic to experts. Apologies in advance!

Although I believe integrating Uglify.js and stylus would enhance the capabilities of this stack, I have been unsuccessful in doing so.

I attempted making changes to the grunt file and server.js, even renaming files, but all I achieved was breaking the original project...

Thank you in advance for any help!

EDIT: Fortunately, I stumbled upon a fork of this project that just added support for Jade templates for public views: https://github.com/tutley/mean

Answer №1

Learn how to add Stylus pre-processing to your MEAN stack with this helpful guide:

Here's a quick summary:

  • Relocate public/css to a new folder called assets/stylesheets and change the file extensions from .css to .styl

  • Use npm to install grunt-contrib-stylus as both a development and runtime dependency.

-Set up stylus compilation in your Gruntfile

// ...
grunt.initConfig({
    // ...
    watch: {
        // ...
        stylus: {
            files: ['assets/stylesheets/**/*.styl'],
            tasks: ['stylus']
        },
        // ...
    },
    // ...
    stylus: {
        compile: {
            options: {
                paths: ['assets/stylesheets/**']
            },
            files: [{
                dest: 'public/css/',
                cwd: 'assets/stylesheets/',
                src: '*.styl',
                ext: '.css',
                expand: true
            }]
        }
    },
    // ...
});
//...
//Load NPM tasks
// ...
grunt.loadNpmTasks('grunt-contrib-stylus');
// ...
  • Include views stylus files (or any sub-stylus) in common.styl using @require

  • Eliminate references to views or other substylesheets in head.jade.

All assets/stylesheets/*.styl files will automatically be compiled into public/css/*.css while grunt is active. To manually trigger a compile, run grunt stylus.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble with incorporating RBAC in React, facing issues with page rendering post successful login

Struggling to incorporate RBAC into my React application, I have a backend in Node.js that is working well, and for the frontend I'm using Vite and React Router DOM v6. To keep things simple, I decided to store the token and role received from the ser ...

How does leaving a comment in a different file impact the overall design of the app in Next.js?

I'm currently working on integrating light and dark themes into a Next.js application. For this, I am utilizing TailwindCSS in combination with next-themes. Strangely enough, even though my system preference theme is set to dark mode, the page initial ...

Using npm with two versions of Python allows you to easily switch between different

Whenever I try to install certain node packages, I encounter errors related to the version of Python. The issue arises from having both Python 2.7 and Python 3.3 (at the time of my last update) installed on my system. However, since only one version can be ...

Ensuring compatibility of peerDependencies through devDependencies in npm3

With the recent update to NPM 3, automatic resolving of peer dependencies has been removed. This poses a challenge when developing a plugin/library for consumption by another application. If the underlying library uses peerDependencies, it requires manual ...

Issue with upgrading node from 12v to 16v: Trying to access a property that does not exist, specifically 'splice', within a circular dependency in module exports

After upgrading the node version from 12 to 16, we encountered a debugging console error. The 'Promises' are failing to resolve following this error, leading to the termination of further execution. (node:28112) Warning: Accessing non-existent p ...

Node Package Manager and yarn.lock file

Ever since the release of NPM v7, the official documentation highlights the behavior of npm install, emphasizing its reliance on package-lock files, npm shrinkwrap files, and now even yarn lock files for dependency installation. While searching for more i ...

Struggling with setting up passport.js. Encountering difficulty fetching the user information

I have a mongodb database where there is a User with the username "testuser", but when I try to login without entering the password, I keep getting an error message saying "failed to login!". I just want to verify that the entered username exists before ch ...

"What is the best way to provide arguments to a Node.js process started using an npm command in VS

In my NodeJS application that I run and debug from VSCode using npm, everything has been working smoothly. Now, I want to enhance the level of detail by adding the runtime argument "--trace-warnings" for node. However, I am struggling to incorporate this i ...

Unable to successfully test POST request with node, express, mocha, and MongoDB

Having trouble with testing POST requests using node, express, mocha, and MongoDB. Oddly enough, the post request works fine in insomnia but I keep getting an error message that says Uncaught AssertionError: expected 404 to equal 200. app.spec.js process. ...

Leveraging git tags within the package.json file for git dependencies

Is there a way to automatically update git dependencies like NPM packages? For example, I have a git dependency: "dependencies": { "my-module": "github:me/my-module" } I want it to be updated every time I run npm install. ...

Error: Invalid Request - Nodejs Request Method

As part of my project involving payment gateway integration, I needed to make a call to the orders api. However, I encountered an error message: {"error":{"code":"BAD_REQUEST_ERROR","description":"Please provide your api key for authentication purposes."} ...

Encounter a problem while installing node modules

I am facing an issue with my test directory which contains a package.json file: { "name": "test", "version": "0.0.1", "dependencies": { "hem": "~0.1.6", } } Upon trying to run node install, I encounter the following error: module.js:337 ...

Firebase Identity Platform Error: Invalid Refresh Token (auth/invalid-refresh-token)

Currently, I am in the process of enhancing an existing Firebase Auth project by transitioning to Identity Platform to take advantage of multi-tenancy features. During my testing phase on the local emulator, I encountered some challenges: Users are not a ...

Is it feasible to retrieve two sets of AWS credentials from a JSON file?

  I am working on developing a node.js express application and I require the ability to access two different sets of credentials depending on the user’s context. Currently, I have configured the app to retrieve one set of credentials from a specific co ...

What is the best way to securely store my API keys on Heroku while ensuring my app can still access them?

I have recently completed developing a Node application and I am now in the process of deploying it on Heroku. Within my app, I utilize various API keys which are stored in a separate file that is accessed using exports throughout the application. The API ...

While running a Conda command through a Node.js script with the use of PM2, I encountered an error stating "/bin/sh: 1: conda: not

Overview In the production environment, I am utilizing pm2 to run a nodejs server. The server executes a javascript file that triggers a python script using the conda run method. Unfortunately, an error occurs with the message: /bin/sh: 1: conda: not foun ...

Running NodeJS scripts with ElectronJS is not possible

Goal I'm facing a challenge with executing my separate scripts located in the project/api folder. Let's take test.js as an example, where I am exporting it using module.exports. When I run my electron window and create a JavaScript file with a f ...

Obtain information from a PHP file using AngularJS 2

Can you guide me on how to post data and receive a response from a PHP page in AngularJS 2? I want to send data from auth.js file to session.php for storing the session value. Please show me how to do this using HTTP POST method. retu ...

Executing a pair of queries within the same table and integrating them within a unified route

How can I efficiently execute two queries on the same table in my project? I have been considering using promises, but my knowledge on them is limited. Even though I've researched about it, I am struggling to implement the correct structure. My main ...

Attempting to install puppeteer within the Visual Studio Code terminal with financial support

I am having trouble installing puppeteer using the VSC terminal. Every time I try to run the npm install command, it doesn't download and prompts me about funding. Can someone please assist me with this issue? npm i puppeteer up to date, audited 67 p ...