Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1130 from colin-marshall/package-task
Browse files Browse the repository at this point in the history
Reintroduce package task
  • Loading branch information
olefredrik authored Oct 15, 2017
2 parents 5da32e3 + 12e5e76 commit 6db244e
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ config.yml
*.log
.idea/
*.swp
packaged/
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ When building for production, the CSS and JS will be minified. To minify the ass
$ npm run build
```

#### To create a .zip file of your theme, run:

```
$ npm run package
```

Running this command will build and minify the theme's assets and place a .zip archive of the theme in the `packaged` directory. This excludes the developer files/directories from your theme like `/node_modules`, `/src`, etc. to keep the theme lightweight for transferring the theme to a staging or production server.

### Project structure

In the `/src` folder you will the working files for all your assets. Every time you make a change to a file that is watched by Gulp, the output will be saved to the `/dist` folder. The contents of this folder is the compiled code that you should not touch (unless you have a good reason for it).
Expand Down
15 changes: 15 additions & 0 deletions config-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,21 @@ PATHS:
# Paths to JavaScript entry points for webpack to bundle modules
entries:
- "src/assets/js/app.js"
# Paths for the package task to include/exclude in .zip archive
package:
- "**/*"
- "!**/node_modules/**"
- "!**/packaged/**"
- "!**/src/**"
- "!**/codesniffer.ruleset.xml"
- "!**/composer.json"
- "!**/composer.lock"
- "!**/config.yml"
- "!**/config.default.yml"
- "!**/gulpfile.babel.js"
- "!**/package.json"
- "!**/package-lock.json"
- "!**/webpack.config.js"

# Set to true if you want static asset revisioning, helpful for cache busting
REVISIONING: false
16 changes: 16 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import gulp from 'gulp';
import rimraf from 'rimraf';
import yaml from 'js-yaml';
import fs from 'fs';
import dateFormat from 'dateformat';
import webpackStream from 'webpack-stream';
import webpack2 from 'webpack';
import named from 'vinyl-named';
Expand Down Expand Up @@ -67,6 +68,10 @@ gulp.task('build',
gulp.task('default',
gulp.series('build', server, watch));

// Package task
gulp.task('package',
gulp.series('build', archive));

// Delete the "dist" folder
// This happens every time a build starts
function clean(done) {
Expand Down Expand Up @@ -146,6 +151,17 @@ function images() {
.pipe(gulp.dest(PATHS.dist + '/assets/img'));
}

// Create a .zip archive of the theme
function archive() {
var time = dateFormat(new Date(), "yyyy-mm-dd_HH-MM");
var pkg = JSON.parse(fs.readFileSync('./package.json'));
var title = pkg.name + '_' + time + '.zip';

return gulp.src(PATHS.package)
.pipe($.zip(title))
.pipe(gulp.dest('packaged'));
}

// Start BrowserSync to preview the site in
function server(done) {
browser.init({
Expand Down
153 changes: 153 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scripts": {
"start": "gulp",
"dev": "gulp build --dev",
"build": "gulp build --production"
"build": "gulp build --production",
"package": "gulp package --production"
},
"keywords": [
"FoundationPress",
Expand Down Expand Up @@ -48,6 +49,7 @@
"gulp-sourcemaps": "^1.6.0",
"gulp-uglify": "^1.2.0",
"gulp-util": "^3.0.8",
"gulp-zip": "^4.0.0",
"js-yaml": "^3.4.6",
"panini": "^1.3.0",
"rimraf": "^2.4.3",
Expand Down

0 comments on commit 6db244e

Please sign in to comment.