ez-web-dev v1.0.2
ez-web-dev
SCSS Compiler with BrowserSync
This project provides a simple setup for live compiling SCSS files to CSS and serving an index.html file using BrowserSync. It's a convenient way to streamline your development workflow.
Prerequisites
Make sure you have Node.js and npm installed on your machine. You can download and install them from Node.js official website.
Contributors
Idea and compilation - exploresahil. Execution and testing - Paragkoche.
Getting Started
Method 1
JavaScript
- using a package manager:
$ npx ez-web-dev@latest- Navigate to the project directory:
$ cd my-app- Update dependencies:
$ npm update- Install dependencies:
$ npm installUsage
Initialize the Project
Create the necessary directories, initial SCSS file, Start the development server, which includes SCSS compilation and BrowserSync:
$ npm run devMethod 2 (Make your Own)
- Make a project folder and create index.html and package.json files.
project-folder/
├── .gitignore # Git ignore file (# optional)
├── LICENSE # License file (# optional)
├── package.json # NPM package configuration
├── README.md # Project README file (# optional)
├── index.html # Main HTML file- Copy the following code and paste it in package.json file.
{
"scripts": {
"init": "node -e \"const fs = require('fs'); if (!fs.existsSync('scss')) { fs.mkdirSync('scss'); } if (!fs.existsSync('scss/styles.scss')) { fs.writeFileSync('scss/styles.scss', ''); }\"",
"compile:scss": "sass --no-source-map --watch scss:css --poll",
"start:scss": "npm run init && npm run compile:scss",
"serve": "browser-sync start --server --port 3000 --files 'css/*.css, *.html'",
"dev": "concurrently \"npm run start:scss\" \"npm run serve\"",
"prebuild": "npm run compile:scss"
}
}- Install latest dependencies as devDependencies.
$ npm i sass@latest browser-sync@latest concurrently@latest --save-devThe Folder structure should look like this:
scss-compiler/
│
├── css/ # Compiled CSS files
│ └── main.css
│
├── scss/ # SCSS source files
│ └── styles.scss
│
├── node_modules/ # Node.js modules and packages
│
├── .gitignore # Git ignore file (# optional)
├── LICENSE # License file (# optional)
├── package.json # NPM package configuration
├── README.md # Project README file (# optional)
├── index.html # Main HTML file
├── package-lock.json # NPM package lock file
├── server.js # Simple server file (if needed)
└── ... # Other project files and directoriesUsage
Initialize the Project
Create the necessary directories, initial SCSS file, Start the development server, which includes SCSS compilation and BrowserSync:
$ npm run devThis command will concurrently run the SCSS compilation and BrowserSync. The BrowserSync UI will be accessible at http://localhost:3000.
Access the Development Server
Visit the development server in your browser at http://localhost:3000. BrowserSync will automatically reload the page whenever changes are made to your CSS or HTML files.
Stop the Development Server
To stop the development server, press Ctrl + C in the terminal.
Customization
Feel free to customize the project structure and SCSS files to suit your needs.
Troubleshooting
If you encounter issues, refer to the following tips:
- Ensure proper termination of the development server.
- Check for running processes related to BrowserSync or Sass after stopping the server.
Update npm packages:
$ npm updateAdjust the Sass watcher with the
--polloption:"compile:scss": "sass --no-source-map --watch scss:css --poll",- Separate watch processes in the "dev" script:
"dev": "npm run start:scss & npm run serve", - Change Port for BrowserSync:
"serve": "browser-sync start --server --port YOUR_NEW_PORT --files 'css/*.css, *.html'",