Table of Contents
Occassionally I need to process a bunch of styles but the project I am working on was built using something like grunt and no longer works. If fixing there build system is outside the scope of what I am supposed to do, then it is useful to have a project like this that I can easily modify and process SCSS and CSS however I want.
- Dart Sass - for compiling .scss to .css
- PostCSS - for processing those .css files
- Autoprefixer - for parsing CSS and add vendor prefixes to CSS rules using values from Can I Use
- CSSNANO - a modular minifier, built on top of the PostCSS ecosystem
- More PostCSS Plugins!
- Have node installed on your machine
- Clone the repo
git clone https://github.com/spaceFitzpa/scss-postcss-compiler.git
- Install NPM packages (Use node version 16.13.0)
npm install
- Add whatever .scss file you want compiled to CSS and processed with PostCSS to
src/styles/scss/
- Update the package.json scripts input and output directories match yours
- Install any PostCSS plugins you intend to use
- Update
postcss.config.js
file with any of the plugins you intend to use
- Run
npm run compile:styles
- This compiles the SCSS from the file you input and outputs the .css and .css.map files into the
src/styles/css
directory. - Then PostCSS runs whatever processes you have applied in the postcss.config.js file to your newly created .css and .css.map files and outputs these processed files into
/dist/styles/css/
- Make sure are using the node version specified in the
package.json
- Make sure you told SASS and PostCSS what input and output files/directories you want to use
- Make sure the postCSS plugin you are trying to use is installed and added to
postcss.config.js
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License.