# simple-preprocess **Repository Path**: mirrors_stevemao/simple-preprocess ## Basic Information - **Project Name**: simple-preprocess - **Description**: Preprocess html, js and css based off environment configuration - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-26 - **Last Updated**: 2025-09-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url] > Preprocess html, js and css based off environment configuration Originally based on [preprocess](https://github.com/jsoverson/preprocess). Created this because I only want to do simpler things with simpler config. ## Install ```sh $ npm install --save simple-preprocess ``` ## Usage ```js var simplePreprocess = require('simple-preprocess'); simplePreprocess('/* @if dev */\nbody {\nbackground: red;\n}\n/* @endif */\n/* @if test*/\n/*body {\nbackground: yellow;\n}*/\n/* @endif*/', 'css', 'dev'); /*=> { data: 'body {\nbackground: red;\n}\n', retained: ['/* @if dev *\/\nbody {\nbackground: red;\n}\n/* @endif *\/\n'], stripped: ['/* @if test*\/\n/*body {\nbackground: yellow;\n}*\/\n/* @endif*\/'] } */ ``` ```sh $ npm install --global simple-preprocess $ simple-preprocess --help Usage simple-preprocess simple-preprocess cat | simple-preprocess Example simple-preprocess env.css css -c 'prod,dev' simple-preprocess env.html html env.html cat env.css | simple-preprocess css -c test cat env.js | simple-preprocess js -c dev > processed.js Options -e, --env Environment -v, --verbose Verbose output ``` ## API ### simplePreprocess(data, type, [env]) #### data Type `string` #### type Type `string` Posible values: `'html'`, `'js'` and `'css'` #### env Type `string` or `array` Default: `process.env.NODE_ENV` ## Task runners - [gulp-simple-preprocess](https://github.com/stevemao/gulp-simple-preprocess) - [grunt-simple-preprocess](https://github.com/stevemao/grunt-simple-preprocess) ## Related If you are using a bundler, you can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build. ## License MIT © [Steve Mao](https://github.com/stevemao) [npm-image]: https://badge.fury.io/js/simple-preprocess.svg [npm-url]: https://npmjs.org/package/simple-preprocess [travis-image]: https://travis-ci.org/stevemao/simple-preprocess.svg?branch=master [travis-url]: https://travis-ci.org/stevemao/simple-preprocess [daviddm-image]: https://david-dm.org/stevemao/simple-preprocess.svg?theme=shields.io [daviddm-url]: https://david-dm.org/stevemao/simple-preprocess [coveralls-image]: https://coveralls.io/repos/stevemao/simple-preprocess/badge.svg [coveralls-url]: https://coveralls.io/r/stevemao/simple-preprocess