├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── assets ├── dist │ └── index.php ├── gulp │ ├── index.php │ ├── tasks │ │ ├── i18n.js │ │ ├── icons.js │ │ ├── imagemin.js │ │ ├── scripts.js │ │ ├── sprites.js │ │ ├── styles.js │ │ └── watch.js │ └── utils │ │ └── handleErrors.js ├── images │ └── index.php ├── index.php ├── js │ └── index.php └── sass │ └── index.php ├── config ├── gulp │ └── config.js └── index.php ├── gulpfile.js ├── index.php └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Unit tests config 2 | phpunit.xml 3 | .travis.yml 4 | /bin 5 | tests/mocks/env/ 6 | 7 | 8 | # Sass cache 9 | .sass-cache/ 10 | 11 | # Development files 12 | /node_modules 13 | /assets/vendor/ 14 | 15 | .idea/ -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.3 (11.July.2017) 2 | 3 | - Fixed [bug #1](https://github.com/KnowTheCode/UpGulp/issues/1) to disable `cleanStyles()` when the package is not theme. 4 | - Passing in `settings` to each function in `gulp/tasks/styles.js` for consistency. 5 | 6 | ## 1.0.2 7 | 8 | - DocBlock cleanup 9 | 10 | ## 1.0.1 11 | 12 | - distFilename configuration added 13 | 14 | ## 23.Oct.2016 15 | 16 | Initial release. -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | GNU General Public License 2.0+ 2 | 3 | This program is free software; you can redistribute it and/or 4 | modify it under the terms of the GNU General Public License 5 | as published by the Free Software Foundation; either version 2 6 | of the License, or (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU General Public License for more details. 12 | 13 | You should have received a copy of the GNU General Public License 14 | along with this program; if not, write to the Free Software 15 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UpGulp 2 | 3 | UpGulp is our gulp module. It contains all of the configuration, setup, and tasks for processing themes, plugins, and whatever else. 4 | 5 | ## Features 6 | 7 | It's modular. Shocking, I know. But navigating one big-butt `gulpfile.js` is a pain in the backside. 8 | 9 | Instead, we split our gulp tasks out in the `assets/gulp/tasks` folder. The main file `gulpfile.js` then loads up all of the configuration (which is stored in `config/gulp/config.js`), plugins, and requirements. Then it calls each of the tasks. Think of it as your Controller or better yet, Task Manager. 10 | 11 | It includes: 12 | 13 | - Scripts 14 | - Concatentates all the scripts found in `assets/js/*.js` 15 | - Renames the combined file with a `.min` suffix 16 | - Minifies that file 17 | - And then stores it into the configured distribution folder, default is `assets/dist/` 18 | - You can name the file whatever you want via the Configuration file 19 | - Styles 20 | - Uses [gulp-sourcemaps](https://www.npmjs.com/package/gulp-sourcemaps) - for debug ease 21 | - Loads in both [Bourbon](https://www.npmjs.com/package/bourbon) and [Neat](https://www.npmjs.com/package/bourbon-neat) 22 | - Process with [gulp-sass](https://www.npmjs.com/package/gulp-sass) 23 | - Runs [postcss](https://www.npmjs.com/package/postcss) 24 | - Includes [sass-rem](https://www.npmjs.com/package/sass-rem) 25 | - [Autoprefix](https://github.com/postcss/autoprefixer) to ensure we get the cross-browser prefixes 26 | - Includes linting using [gulp-sass-lint](https://www.npmjs.com/package/gulp-sass-lint) 27 | - Copy and rename the full stylesheet with a `.min` suffix 28 | - It minifies to optimize the stylesheet 29 | - If this is a theme, then it moves both the `.css` and `.min.css` files to the root of the theme folder. 30 | - Translations 31 | - i18n translations are included (NEEDS TESTING) 32 | - Sprites and icons optimizations 33 | - Imagine optimizations 34 | 35 | ### Sass Features 36 | 37 | This gulp starter has Bourbon, Neat, and Sass REM baked into it. To use these in your `style.scss` file and project, do the following: 38 | 39 | ``` 40 | @import 'bourbon'; 41 | @import 'neat'; 42 | @import '../../node_modules/sass-rem/rem'; 43 | ``` 44 | 45 | REM is being deprecated out of Bourbon. Using the `sass-rem` module lets us import the functionality we want. To convert pixels into rems, add the following into your Sass declaration: 46 | 47 | `@include rem( font-size, 18px );` 48 | 49 | You can learn more about the syntax in the [documentation](https://www.npmjs.com/package/sass-rem#scss); 50 | 51 | ## Installation: 52 | 53 | 1. Open up terminal and navigate to the theme, plugin, or proper folder. 54 | 2. Then type: `git clone https://github.com/KnowTheCode/UpGulp.git`. The repository is loaded into a new subfolder called UpGulp. 55 | 3. Now it's time to move the contents of `UpGulp` folder into the root of your plugin or theme. 56 | - Move `gulpfile.js`, `package.json`, `config/gulp`, and `assets/gulp` 57 | - Move these resources into the root of your theme or plugin 58 | 4. Type `npm install`. It will automatically install all of the modules specified in the `package.json` file. 59 | 5. Change the configuration parameters in the variable `moduleSettings` as found in `config/gulp/config.js`. You will want to change: 60 | - `moduleSettings.package` -> change to the package's name 61 | - `moduleSettings.domain` -> change to the domain name 62 | - `moduleSettings.isTheme` -> If this is a theme, then set it to `true`. 63 | - `moduleSettings.i18n` -> Define the i18n parameters 64 | 65 | ### Run it 66 | 67 | To run it, open terminal and type `gulp watch`. There are various watchers available including: 68 | 69 | - `gulp scripts` 70 | - `gulp styles` 71 | - `gulp sprites` 72 | - `gulp i18n` 73 | - `gulp icons` 74 | - `gulp imagemin` 75 | 76 | ## Credit 77 | 78 | This gulp setup is inspired by [WebDev Studio's setup](https://github.com/WebDevStudios/wd_s/blob/master/Gulpfile.js). 79 | 80 | ## Contributions 81 | 82 | All feedback, bug reports, and pull requests are welcome. 83 | 84 | ## TODOs 85 | 86 | There are things we need to improve and test in this starter module including: 87 | 88 | - Automate the installation process 89 | - Test sprites and translations 90 | -------------------------------------------------------------------------------- /assets/dist/index.php: -------------------------------------------------------------------------------- 1 | ', 24 | message: 'See console.', 25 | sound: 'Sosumi' // See: https://github.com/mikaelbr/node-notifier#all-notification-options-with-their-defaults 26 | } ).apply( this, args ); 27 | 28 | gutil.beep(); // Beep 'sosumi' again 29 | 30 | // Prevent the 'watch' task from stopping 31 | this.emit( 'end' ); 32 | }; -------------------------------------------------------------------------------- /assets/images/index.php: -------------------------------------------------------------------------------- 1 | ', 31 | team: 'Team ' 32 | } 33 | }; 34 | 35 | 36 | /************************************ 37 | * Folder Structure 38 | ***********************************/ 39 | 40 | /** 41 | * Assets folder - path to the location of all the assets, 42 | * i.e. images, Sass, scripts, styles, etc. 43 | * 44 | * @type {String} 45 | */ 46 | var assetsDir = moduleRoot + 'assets/'; 47 | 48 | /** 49 | * gulp folder - path to where the gulp utils and 50 | * tasks are located. 51 | * 52 | * @type {String} 53 | */ 54 | var gulpDir = assetsDir + 'gulp/'; 55 | 56 | /** 57 | * Distribution folder - path to where the final build, distribution 58 | * files will be located. 59 | * 60 | * @type {String} 61 | */ 62 | var distDir = assetsDir + 'dist/'; 63 | 64 | /** 65 | * Assets folder - path to where the raw files are located. 66 | * 67 | * @type {Object} 68 | */ 69 | var assetDirs = { 70 | css: assetsDir + 'css/', 71 | fonts: assetsDir + 'fonts/', 72 | icons: assetsDir + 'icons/', 73 | images: assetsDir + 'images/', 74 | sass: assetsDir + 'sass/', 75 | scripts: assetsDir + 'js/' 76 | } 77 | 78 | /** 79 | * Paths 80 | * 81 | * @type {Object} 82 | */ 83 | var paths = { 84 | css: ['./*.css', '!*.min.css'], 85 | icons: assetDirs.images + 'svg-icons/*.svg', 86 | images: [ assetDirs.images + '*', '!' + assetDirs.images + '*.svg' ], 87 | php: [ moduleRoot + '*.php', moduleRoot + '**/*.php'], 88 | sass: assetDirs.sass + '**/*.scss', 89 | concatScripts: assetDirs.scripts + '*.js', 90 | scripts: [ assetDirs.scripts + '*.js', '!' + assetDirs.scripts + '*.min.js' ], 91 | sprites: assetDirs.images + 'sprites/*.png' 92 | }; 93 | 94 | /** 95 | * Distribution folder - path to where the final build, distribution 96 | * files will be located. 97 | * 98 | * @type {Object} 99 | */ 100 | var distDirs = { 101 | root: moduleRoot, 102 | css: distDir + 'css/', 103 | finalCSS: moduleSettings.isTheme ? moduleRoot : distDir + 'css/', 104 | scripts: distDir + 'js/' 105 | }; 106 | 107 | var distFilenames = { 108 | concatScripts: 'jquery.project.js' 109 | }; 110 | 111 | /************************************ 112 | * Theme Settings 113 | ***********************************/ 114 | 115 | var stylesSettings = { 116 | clean: { 117 | src : [ distDirs.css + "*.*", moduleRoot + "style.css", moduleRoot + "style.min.css" ] 118 | }, 119 | postcss: { 120 | src: [ assetDirs.sass + '*.scss' ], 121 | dest: distDirs.css, 122 | autoprefixer: { 123 | browsers: [ 124 | 'last 2 versions', 125 | 'ie 9', 126 | 'ios 6', 127 | 'android 4' 128 | ] 129 | } 130 | }, 131 | cssnano: { 132 | src: distDirs.css + "*.css", 133 | dest: distDirs.css, 134 | }, 135 | cssfinalize: { 136 | // Fix for Issue #1 - v1.0.3 11.July.2017 137 | run: moduleSettings.isTheme ? true : false, 138 | src: [ distDirs.css + "style.css", distDirs.css + "style.min.css" ], 139 | dest: distDirs.finalCSS, 140 | } 141 | }; 142 | 143 | var scriptsSettings = { 144 | clean: { 145 | src : [ distDirs.scripts + "*.*" ] 146 | }, 147 | concat: { 148 | src: paths.concatScripts, 149 | dest: distDirs.scripts, 150 | concatSrc: distFilenames.concatScripts, 151 | }, 152 | uglify: { 153 | src: distDirs.scripts + '*.js', 154 | dest: distDirs.scripts, 155 | } 156 | }; 157 | 158 | var i18nSettings = { 159 | clean: { 160 | src : [ moduleRoot + "languages/" + moduleSettings.i18n.languageFilename ] 161 | }, 162 | pot: { 163 | src: paths.php, 164 | wppot: { 165 | domain: moduleSettings.i18n.textdomain, 166 | destFile: moduleSettings.i18n.languageFilename, 167 | package: moduleSettings.package, 168 | bugReport: moduleSettings.i18n.bugReport, 169 | lastTranslator: moduleSettings.i18n.lastTranslator, 170 | team: moduleSettings.i18n.team 171 | }, 172 | dest: moduleRoot + "languages/" 173 | } 174 | } 175 | 176 | var iconsSettings = { 177 | clean: { 178 | src : [ assetDirs.images + "svg-icons.svg" ] 179 | }, 180 | svg: { 181 | src: paths.icons, 182 | desc: assetDirs.images 183 | } 184 | } 185 | 186 | var spriteSettings = { 187 | clean: { 188 | src : [ assetDirs.images + "sprites.png" ] 189 | }, 190 | spritesmith: { 191 | src: paths.sprites, 192 | dest: assetDirs.images 193 | } 194 | } 195 | 196 | var imageminSettings = { 197 | src: paths.images, 198 | dest: assetDirs.images 199 | } 200 | 201 | var watchSettings = { 202 | browserSync: { 203 | open: false, // Open project in a new tab? 204 | injectChanges: true, // Auto inject changes instead of full reload 205 | proxy: moduleSettings.domain, // Use http://domainname.tld:3000 to use BrowserSync 206 | watchOptions: { 207 | debounceDelay: 1000 // Wait 1 second before injecting 208 | } 209 | } 210 | } 211 | 212 | 213 | /************************************ 214 | * Do not touch below this line. 215 | * 216 | * The following code assembles up the 217 | * configuration object that is returned 218 | * to gulpfile.js. 219 | ***********************************/ 220 | 221 | return { 222 | moduleRoot: moduleRoot, 223 | assetsDir: assetsDir, 224 | assetDirs: assetDirs, 225 | dist: distDirs, 226 | distDir: distDir, 227 | gulpDir: gulpDir, 228 | paths: paths, 229 | 230 | i18n: i18nSettings, 231 | icons: iconsSettings, 232 | images: imageminSettings, 233 | scripts: scriptsSettings, 234 | sprites: spriteSettings, 235 | styles: stylesSettings, 236 | watch: watchSettings 237 | }; 238 | }; -------------------------------------------------------------------------------- /config/index.php: -------------------------------------------------------------------------------- 1 |