A fast, modern starter template for vanilla JavaScript and Sass, powered by Vite. Includes comprehensive linting, formatting, image optimization, HTML minification, and legacy browser support. Perfect for performant, framework-free frontend apps with strict code quality.
- β‘οΈ Lightning-fast development with Vite
- π§± Pure Vanilla JS & Sass (no frameworks)
- π§Ή Integrated linting for HTML, CSS/SCSS, and JS
- πΌοΈ Automated image optimization
- π§ Minified and templated HTML
- πΈοΈ Legacy browser compatibility
- π Autoprefixing for cross-browser CSS
- π§ͺ Testing with Vitest
- π Pre-commit hooks with Husky & lint-staged
- π CI/CD pipeline with GitHub Actions
- Build: Vite
- Language: Vanilla JavaScript
- Styles: Dart Sass, modern-normalize
- Linting: ESLint, Stylelint, HTMLHint
- Formatting: Prettier
- Testing: Vitest
- Git Hooks: Husky, lint-staged
- CI/CD: GitHub Actions
- Images: vite-plugin-imagemin
- HTML: vite-plugin-html
- PostCSS: Autoprefixer
- Legacy: @vitejs/plugin-legacy
src/β Source files (HTML, JS, SCSS, assets)dist/β Production build outputindex.htmlβ Entry HTML filevite.config.jsβ Vite configpostcss.config.jsβ PostCSS configeslint.config.js,.stylelintrc,.htmlhintrcβ Lint configsprettier.config.mjsβ Formatting configpackage.jsonβ Scripts & dependencies.vscode/β VSCode workspace settings and recommended extensions
This starter supports modern browsers and legacy browsers (excluding IE 11) via @vitejs/plugin-legacy:
- Modern browsers: Latest versions of Chrome, Firefox, Safari, Edge
- Legacy browsers: Older versions with automatic polyfills and transpilation
- Target:
defaults, not IE 11(configured invite.config.js)
The build process generates both modern and legacy bundles for optimal performance and compatibility.
vite-plugin-htmlβ Minifies HTML + template supportvite-plugin-imageminβ Optimizes imagesvite-plugin-eslint2β Lints JSvite-plugin-stylelintβ Lints SCSS@vitejs/plugin-legacyβ Legacy browser support
Note: The project uses
.nvmrcto specify the Node.js version. If you usenvm, runnvm useto automatically switch to the correct version.
npx degit marcop135/vite-vanilla-sass-lint my-app
cd my-app
npm install
npm run devnpm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Lint html, css, scss, and js files
npm run lint:fix # Lint and auto-fix issues
npm run format # Format html, css, scss, js, and md files
npm run format:check # Check code formatting
npm run test # Run tests
npm run test:ui # Run tests with UI
npm run test:coverage # Run tests with coverage
npm run clean # Remove dist folder
npm run audit # Check for security vulnerabilities
npm run audit:fix # Fix security vulnerabilitiesIncludes:
eslintβ Lint JavaScript (configured ineslint.config.js)stylelintβ Lint CSS/SCSS (configured in.stylelintrc)htmlhintβ Lint HTML/JSX (configured in.htmlhintrc)prettierβ Format code (configured inprettier.config.mjs)
ESLint (eslint.config.js):
- Enforces strict equality (
===) - Warns on camelCase violations
- Errors on undefined variables and unused vars
- Browser globals enabled
Stylelint (.stylelintrc):
- Extends
stylelint-config-standard-scss - Validates SCSS syntax and best practices
- Custom rules for project flexibility
HTMLHint (.htmlhintrc):
- Enforces lowercase tags and attributes
- Requires double quotes for attributes
- Validates unique IDs and required attributes
npm run lint
npm run formatnpx eslint "src/assets/js/*.js"
npx stylelint "src/assets/scss/*.{scss,css}"
npx htmlhint "**/*.html"
npx prettier --check "src/**/*.{js,css,scss,html,md}"This project uses Vitest for testing.
npm run test # Run tests in watch mode
npm run test:ui # Run tests with UI
npm run test:coverage # Run tests with coverage report- Test files should be named
*.test.jsor*.spec.js - Place test files next to the code they test or in a
__tests__directory - Use Vitest's API:
describe,it,expect, etc.
Example test:
import { describe, it, expect } from 'vitest';
describe('My Feature', () => {
it('should do something', () => {
expect(true).toBe(true);
});
});- Vite Docs
- Sass Docs
- Modern Normalize
- Autoprefixer
- HTMLHint
- Stylelint
- ESLint
- Vitest
- Husky
- Vite Plugins:
Contributions welcome! Please read CONTRIBUTING.md for guidelines on how to contribute.
- π Found a bug? Open an issue
- π‘ Have a feature request? Open an issue
- π Want to contribute? Read the contributing guide
Licensed under the MIT License.