![]() Just as we did above, I took my minification code in my gulpfile:Īnd told it to run with production only with mode.production I wanted gulp to minify my style.css on production, not development. You get the point.Įxample 2: Enable minification only on production So if you are doing a gulp build, then gulp build -development a gulp watch, then gulp watch -development or gulp watch -production. Still, how does it know what is development and what is not?īecause you tell it when you run gulp by adding the suffix -development or -production. To do this I need to locate the sourcemaps code in my gulpfile:Īnd since I want this to happen only in development, I simply add velopment to my desired function: Here are my two examples, sourcemaps and minification.Įxample 1: Disable sourcemaps on production How does it know what environment we are on? Well, we tell it. Your gulp still runs normally.īut with our gulp-mode package, we can now tell specific tasks to only run on production or only run on development. Step 2: Choosing Production or Development Now require it at the top of your gulp file: ![]() ![]() In your terminal run the command: npm i gulp-mode (or npm i gulp-mode -save-dev to save as a dependency in your json file (recommended)). So if this peaks your interest, here is how to easily do it: Run Gulp Tasks According To Environment Step 1: Install node-gulp-mode I wanted to minify my style.css in production only.I wanted a sourcemap in development, but have it removed in production.I had two reasons for the need to run gulp tasks according to environment: So in taking the time to rebuild my own site from scratch with gulp and Sass, I want to share specifically an easy way to run gulp tasks according to environment whether production or development. I'm not new to gulp or Sass, using it regularly in the freelance work that I do, but often the gulp file, or gulp template, is pre-determined by another designer, developer, or agency. Irecently redesigned my website and in doing so I wanted to really dig into the benefits of gulp and Sass in website development.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |